![](/img/trans.png)
[英]My print statement just won't run even when there aren't any errors in the output and it's hard to trace the error
[英]How to print exception errors and trace tacks in a file when there's an error in my code?
我希望每當我的代碼中出現錯誤時, traceback.print_exception()
就會執行,這樣我就可以檢查文件中的任何錯誤......有可能以某種方式嗎?
您可以嘗試將代碼包裝在 try/except 塊中,然后在 except 中調用該函數。 它可能看起來像這樣:
try:
# Your code here
except Exception as e:
traceback.print_exception(e)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.