6
在代码中有不同的老式类像这样的:如何捕捉python中的所有旧式类异常?
class customException: pass
和异常升高是这样的:
raise customException()
有没有一种类型来捕获所有那些旧式类异常?像这样:
try:
...
except EXCEPTION_TYPE as e:
#do something with e
或者至少有一种方法可以捕捉一切(旧式和新式)并获取变量中的异常对象?
try:
...
except:
#this catches everything but there is no exception variable
相关:http://python3porting.com/differences.html#except –