如何在不执行Python脚本的情况下检查其语法? [英] How can I check the syntax of Python script without executing it?
本文介绍了如何在不执行Python脚本的情况下检查其语法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我曾经使用 perl -c程序文件
检查Perl程序的语法,然后退出而不执行它。
I used to use perl -c programfile
to check the syntax of a Perl program and then exit without executing it. Is there an equivalent way to do this for a Python script?
推荐答案
您可以通过编译它来检查语法:
You can check the syntax by compiling it:
python -m py_compile script.py
这篇关于如何在不执行Python脚本的情况下检查其语法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文