python实例 异常处理

#! /usr/bin/python
s=input("Input your age:")
if s =="":
    raise Exception("Input must no be empty.")

try:
    i=int(s)
except Exception as err:
    print(err)
finally: # Clean up action
    print("Goodbye!")

posted @ 2019-07-25 14:04  樊伟胜  阅读(483)  评论(0编辑  收藏  举报