1. 程式人生 > >sys.exc_info()可以捕獲到任意異常

sys.exc_info()可以捕獲到任意異常

code try except 返回 print pre () port pan

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()可以捕獲到任意異常