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

猜你喜欢

转载自www.cnblogs.com/lianghong881018/p/11081728.html
今日推荐