相关疑难解决方法(0)

从异常对象中提取回溯信息

给定一个Exception对象(来源不明)有没有办法获得它的追溯?我有这样的代码:

def stuff():
   try:
       .....
       return useful
   except Exception as e:
       return e

result = stuff()
if isinstance(result, Exception):
    result.traceback <-- How?
Run Code Online (Sandbox Code Playgroud)

有了它,如何从Exception对象中提取回溯?

python debugging exception-handling

95
推荐指数
6
解决办法
5万
查看次数

标签 统计

debugging ×1

exception-handling ×1

python ×1