python 检查当前目录树中的所有python文件以进行编译

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 检查当前目录树中的所有python文件以进行编译相关的知识,希望对你有一定的参考价值。

import compileall
import os
import sys

# Get path of this file's directory
directory = os.path.dirname(os.path.realpath(__file__))

# Check that files are compileable
success = compileall.compile_dir(dir=directory, maxlevels=20, force=True)

# Return appropriate exit code
sys.exit(0) if success else sys.exit(1)

以上是关于python 检查当前目录树中的所有python文件以进行编译的主要内容,如果未能解决你的问题,请参考以下文章