python exception

try:
    x = input('enter the first number:')
    y= input('enter the second number:')
    print(int(x)/int(y))
except (ZeroDivisionError, TypeError, NameError) as e:
    print(e)
finally:
    print("clean up")

result:

enter the first number:5
enter the second number:1
5.0
clean up
原文地址:https://www.cnblogs.com/lianghong881018/p/11081728.html