复习贴-python的文件类型

来源:互联网 发布:云计算ppt模板百度云 编辑:程序博客网 时间:2024/05/16 15:08
1.创建一个 hello word的py文件 文件执行

2 .源代码
python的源代码文件以py为扩展名结尾的,由python程序解释,不需要编译。

字节代码
python源文件经编译后生成的扩展名“pyc”的文件
-编译方法
import py_compile
py_compile.compile("hello.py")



优化代码
经过优化的代码文件,扩展名为'pyo'的文件
python -O -m py_compile hello.py

tip~
一般都写源码py文件,如果你想写的文件不让别人看,用py_compile 编译成代码。