def mye( level ):
if level < 1:
raise Exception,"Invalid level!"
# 触发异常后,后面的代码就不会再执行
if __name__ == "__main__":
try:
mye(0)
except Exception,err: # err为发生异常的信息
print 1,err
else: # 没有发生异常执行
print 2
finally: # 无论是否异常都执行
print "finally"