python编译模块为2禁制

编译模块为2禁制
yum -y install python26-setuptools
easy_install -U setuptools
# cd /usr/lib64/python2.6
# easy_install py_compile

python -O -m py_compile file.py

-O 优化成字节码
-m 表示把后面的模块当成脚本运行
-OO 表示优化的同时删除文档字符串


也可以写一个脚本来实现:
Python代码
import py_compile

py_compile.compile("file_path")

posted on 2014-09-28 15:56  @Jin  阅读(231)  评论(0编辑  收藏  举报

导航