2024-05-19 11:30:19 发布
网友
Possible Duplicate:How can I check the syntax of Python script without executing it?
如何在不运行Python脚本的情况下编译它?我只想检查脚本的语法错误。我希望有一个简单的命令行切换,但是在python --help中没有看到任何内容。我想要Python 2和Python 3的答案。
python --help
py_compile — Compile Python source files
import py_compile py_compile.compile('my_script.py')
python -m py_compile script.py
您可以使用pylint查找语法错误以及更细微的错误,例如在一些很少使用的条件分支中访问未定义的变量。
py_compile — Compile Python source files
您可以使用pylint查找语法错误以及更细微的错误,例如在一些很少使用的条件分支中访问未定义的变量。
相关问题 更多 >
编程相关推荐