异常的捕捉与raise
def mye( level ):
if level < 1:
raise Exception("Invalid level!", level) # 不能使用return返回异常,就捕捉不到
try:
mye(0)
except Exception as e:
print (1)
异常的捕捉与raise
def mye( level ):
if level < 1:
raise Exception("Invalid level!", level) # 不能使用return返回异常,就捕捉不到
try:
mye(0)
except Exception as e:
print (1)