为了加密 .py 文件,以前一般使用打包成 exe ,但是最近发现可以将其编译成二进制文件 pyc ,虽然反编译难度不大,但是也需要一些水平
pyc:单个文件
代码:
import py_compile
py_compile.compile("test.py")命令行下:
python -m py_compile test.py多个文件
import compileall
compileall.compile_dir("存放海量py的目录")命令行下:
python -m compileall 存放海量py的目录pyc 文件命令行下:
python test.pyc
pyc首先安装库 uncompyle
pip install uncompyle

查看 uncompyle 函数属性:

命令行下:
uncompyle6 test.pyc > test1.py和源文件对比:
