一.使用taceback模块打印异常信息
import traceback
try:
print("----------------------")
print(2/0)
except:
traceback.print_exc()
打印:
----------------------
Traceback (most recent call last):
print(2/0)
ZeroDivisionError: division by zero
一.使用taceback模块打印异常信息
import traceback
try:
print("----------------------")
print(2/0)
except:
traceback.print_exc()
打印:
----------------------
Traceback (most recent call last):
print(2/0)
ZeroDivisionError: division by zero