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

 

posted @ 2019-06-25 11:15  嵌入式实操  阅读(123)  评论(0编辑  收藏  举报