#捕捉对象:让程序继续运行,但是又因为某种原因记录下错误给用户看
try:
x = input('Enter the first number:')y = input('Enter the second number:')
print x/y
except (ZeroDivisionError,TypeError,NameError),e:
print e
运行结果:
注意:在python3.0中,except子句会被写作except (ZeroDivisionError,TypeError,NameError) as e: