异常处理简单例子--python

Posted littlevigra

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了异常处理简单例子--python相关的知识,希望对你有一定的参考价值。

捕获所有异常

#!/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










以上是关于异常处理简单例子--python的主要内容,如果未能解决你的问题,请参考以下文章