打印堆栈信息,方便调试
方式一:
import tracebackdef test(self):try:1 / 0except BaseException as e:msg = traceback.format_exc()print(msg)finally:pass
方式二:
import loggingdef test(self):try:1 / 0except BaseException as e:# msg = traceback.format_exc()msg = logging.exception(e)print(msg)finally:pass
