# Python 打包产物最小解析示例 以下示例以本机 Python 3.14.7 与 PyInstaller 6.22.2 为标本,命令与输出可原样复现(工具链:`python3`、`pip install pyinstaller pyinstxtractor-ng`;系统 pip 受 PEP 668 限制时先 `python3 -m venv` 再装)。结构定义见 [[layout]]。 ## 1. pyc 头解析(python3 本机可复现) ### 生成 pyc ```sh python3 -c "import py_compile; py_compile.compile('sample.py', cfile='sample.pyc')" # sample.py 内容:import base64 # k = base64.b64decode("czNjcmV0") # print(k) ``` ### struct 解析头 + marshal 验证 + 反汇编 ```python import struct, marshal, dis d = open('sample.pyc', 'rb').read() magic, flags, mtime, size = struct.unpack('