python异常处理
- sys.exc_info() 获取异常
import sys
try:
raise ValueError('this is a exp')
except Exception as ex:
ex_type, ex_val, ex_stack = sys.exc_info()
print(ex_type)
print(ex_val)
import sys
try:
raise ValueError('this is a exp')
except Exception as ex:
ex_type, ex_val, ex_stack = sys.exc_info()
print(ex_type)
print(ex_val)