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