import traceback
def fun(a,b):
return a/b
try:
fun(1,0)
except Exception as e:
traceback.print_exc()
#或者得到堆栈字符串信息
info = traceback.format_exc()
import traceback
def fun(a,b):
return a/b
try:
fun(1,0)
except Exception as e:
traceback.print_exc()
#或者得到堆栈字符串信息
info = traceback.format_exc()