python基本操作杂记

陆续补充 ,自用

生成单个pyc文件

对于py文件,可以执行下面命令来生成pyc文件。

python -m bar.py

另外一种方式是通过代码来生成pyc文件。

import py_compile
py_compile.compile('/path/to/bar.py')

批量生成pyc文件

针对一个目录下所有的py文件进行编译。python提供了一个模块叫compileall,具体请看下面代码:

import compileall
compileall.compile_dir(r'/path')

猜你喜欢

转载自blog.csdn.net/m0_37329910/article/details/86588632