我正在尝试检查 python 代码中的错误,我需要访问错误日志本身(我不能只检查.pyc文件是否已创建)。
我目前的流程是我有一个要运行的脚本python3 -m py_compile test.py,其中test.py“aegsedrg”在哪里,没有别的(换句话说,无效的python代码)。
当 python3 test.py运行时,其结果是错误的(如预期):
Traceback (most recent call last):
File "test.py", line 1, in <module>
aegsedrg
NameError: name 'aegsedrg' is not defined
但是,python3 -m py_compile test.py返回(通过 stdout 或 stderr)没有错误。
这是在 Ubuntu 16.04 服务器上,我最近对其进行了升级和更新。我也完全重新安装了 Python 3。我认为这不是权限问题,test.py是 777。
为什么python3 -m py_compile test.py什么都不返回?
-编辑-
我还尝试使用以下 python 脚本来执行此操作:
import py_compile
print("Here")
py_compile.compile("test.py")
print("Here2")
输出是“Here”,然后是“Here2”。
四季花海
相关分类