2018-06-01 python印刷エラースタック
380 ワード
import logging
import traceback
def testPrintStackInfo(self):
try:
1 / 0 #
except BaseException as e:
# 1
msg = traceback.format_exc()
print (msg)
# 2
logging.exception(e)
finally:
pass
エラーがなければmsgはNoneです.