Get exception description and stack trace which caused an exception

import traceback

try:
    raise ValueError
except:
    tb = traceback.format_exc()
else:
    tb = "No error"
finally:
    print tb

Original: http://stackoverflow.com/questions/4564559/get-exception-description-and-stack-trace-which-caused-an-exception-all-as-a-st

原文地址:https://www.cnblogs.com/feisky/p/2806974.html