异常处理简单例子--python except Exception as e

捕获所有异常

#!/usr/bin/python
a = 10
b = 0
try:
c = a/b
print c
print 'nothing happen...'
#todo: catch all exception
except Exception,e:
print 'bad sth happen...',Exception,":",e

posted @ 2018-03-01 11:57  littlevigra  阅读(14416)  评论(0编辑  收藏  举报