如何從Exception對象本身獲取完整的堆棧跟蹤?如何從Python中的異常對象獲取堆棧跟蹤?
考慮下面的代碼作爲降低該問題的例子:
last_exception = None
try:
raise Exception('foo failed')
except Exception as e:
last_exception = e
# this happens somewhere else, decoupled from the original raise
print_exception_stack_trace(last_exception)
可能的重複[你如何檢查Python的異常的堆棧跟蹤?](http://stackoverflow.com/questions/2359248/how-can-you-inspect-the-stack-trace-of-一個例外的蟒蛇) – 2010-07-29 11:28:23
嗯,是的,但這個問題沒有(令人滿意)回答! – katrielalex 2010-07-29 11:31:01