捕获 python 异常
import sys
try:
x = input('input the first number:')
y = input('input the second number:')
print('x/y = ', x/y)
exception (ZeroDivisionError, TypeError, Number) as e:
#exception (ZeroDivisionError, TypeError, Number), e python2.x
print('your number is bogus')
print e
- 打印输出异常,便于排查问题