频道栏目
首页 > 资讯 > Python > 正文

python 3.3 try..catch 小例

13-06-07        来源:[db:作者]  
收藏   我要投稿

[python]
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!") 

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!")


运行结果:

 
 


 

相关TAG标签
上一篇:整数分解成多个连续的整数序列
下一篇:删除ubuntu中旧的kernel
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站