所以我知道我可以使Python可执行pyinstaller
。
但是,每当它引发错误时,它都会立即结束程序,所以我找不到错误所在。
我知道我可能可以使用time.sleep(30000)
它来停止它。
但是,如果代码在遇到之前就引发了错误time.sleep(30000)
,它将关闭。
综上所述,如何使其不关闭,所以我可以看到错误在哪里?
如果仅通过双击运行可执行文件,请尝试从控制台运行它。例如在Windows中:
在cmd中运行
cd executable_path myexecutable.exe
更好的方法是引入记录器,以便其他实现了记录的模块可以写入文件。
另外,您可以将代码放在try-except块中:
try:
#my_code_here
print('Here is where the exception is')
except Exception as e:
print('Unexpected error:' + str(e))
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句