首页 > 编程语言 > 详细

python handle exception

时间:2014-09-18 13:09:03      阅读:316      评论:0      收藏:0      [点我收藏+]

1. handle exception

import sys

try:
     a=1/1
except Exception, e:
     print "failed", sys.exc_info()[0]
else:
    print "no exception"
finally:
    print "execute final"

2. print exception

try:
    raise Exception("aaa","bbb")
    #a=1/0
except Exception as e :
     print (type(e))
     print(e.args)
     print (e)

 

python handle exception

原文:http://www.cnblogs.com/phoenix13suns/p/3978929.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!