python3中打印异常堆栈信息

import traceback
def fun(a,b):
    return a/b
try:
    fun(1,0)
except Exception as e:
    traceback.print_exc()
    #或者获得堆栈字符串信息
    info = traceback.format_exc()
相关文章
相关标签/搜索