Exception handling 如何在Python中检查多个异常?

Exception handling 如何在Python中检查多个异常?,exception-handling,python-2.6,Exception Handling,Python 2.6,DNASequence=“laksjfklsajfklasjfklsad” 问题是,input返回一个字符串,然后将if中的该字符串与int进行比较。在python 2.x中,应该使用raw\u input而不是input: DNASequence = "laksjfklsajdfklsajfklasjfklsad" while True: try: lMerLength = int(raw_input("Please enter the length of the l-

DNASequence=“laksjfklsajfklasjfklsad”


问题是,
input
返回一个字符串,然后将if中的该字符串与int进行比较。在python 2.x中,应该使用
raw\u input
而不是
input

DNASequence = "laksjfklsajdfklsajfklasjfklsad"
while True:
    try:
        lMerLength = int(raw_input("Please enter the length of the l-mers of the universal array :"))
    except ValueError:
        print "ERROR: Please check your input. You entered an invalid input."
        continue
    if len(DNASequence) >= lMerLength > 0:
        break
    print "ERROR: Please check your input. You entered an invalid input."

下面是检查多个异常的方法

尝试:

除了(SyntaxError、NameError,…):

最后:

    .............
“这不起作用”:为什么不起作用?你有例外吗?意外的行为?顺便问一下:你为什么要处理一个
语法错误
    ..............
    ..............
    .............