python列印堆疊資訊
阿新 • • 發佈:2018-11-13
分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow
也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!
import logging
import traceback
def testPrintStackInfo(self): try: 1 / 0 # 觸發異常 except BaseException as e: msg = traceback.format_exc() # 方式1 print (msg) logging.exception(e) # 方式2 finally: pass ### ---------------------------------------------------------------------------------------------