首页 > 代码库 > sys.exc_info()可以捕获到任意异常

sys.exc_info()可以捕获到任意异常

1 import sys
2 try:
3     a = 3
4     assert a > 4
5 except:
6     exc = sys.exc_info()#返回异常的元祖
7     print (exc)

 

sys.exc_info()可以捕获到任意异常