对python源码进行编译,加密python脚本
对python源码进行编译 1.生成.pyc文件 import py_compile py_compile.compile('hello.py') 2.优化源码文件 python -O -m py_compile 1.py 生成.pyo文件 例子: 1 [root@lvs-master tool] # python3 2 Python 3.5.6 (default, May 3 2019, 01:52:28 ) 3 [GCC 4.8.5 20150623 (Red Hat 4.8.5-36 )] on linux 4 Type " help " , " copyright " , " credits " or " license " for more information. 5 >>> import py_compile 6 >>> py_compile.compile( ' test_conn_linux.py ' ) 7 ' __pycache__/test_conn_linux.cpython-35.pyc ' 8 >>> 9 >>> exit 10 Use exit() or Ctrl- D (i.e. EOF) to exit 11 12 # 执行部分 13 [root@lvs-master __pycache__ ] # python3 test_conn_linux