python 3.3 try..catch 小例

来源:互联网 发布:飞机大战子弹算法 编辑:程序博客网 时间:2024/06/05 10:03
s=input("input your age:")if s=="":raise Exception("input must not be empty.")try:i=int(s)except Exception as err:print(err)finally:print("Goodbye!")


运行结果:


原创粉丝点击