码迷,mamicode.com
首页 > 编程语言 > 详细

python handle exception

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

标签:style   blog   color   io   ar   div   sp   log   on   

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

标签:style   blog   color   io   ar   div   sp   log   on   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!