Python文件类型
源代码
- Python源代码的文件以“py”为扩展名,由Python程序解释,不需要编译
字节代码
- Python源文件经编译后生成的扩展名为“pyc”的文件
编译方法
import py_compile py_compile.compile("hello.py")
优化代码
- 经过优化的源文件,扩展名为“.pyo”
python -O -m py_compile hello.py
编译方法
import py_compile
py_compile.compile("hello.py")
python -O -m py_compile hello.py
原文:https://www.cnblogs.com/zfc2201/p/8168923.html