#!/usr/bin/python
# -*- coding: UTF-8 -*-
if __name__ == "__main__":
print "hello world"
源代码文件hello.py
import py_compile
py_compile.compile("hello.py")
编译脚本文件hello_compile.py
hello.py为Python语言的hello_world脚本
运行hello_compile.py可将hello.py编译为字节码文件hello.pyc
也可以使用”python -m py_compile hello.py“将hello.py编译为hello.pyc文件
字节码文件可以通过python hello.pyc执行,也可双击执行
使用”python -O -m py_compile hello.py“可将hello.py编译为hello.pyo文件
pyo为优化编译文件可以通过python hello.pyc执行,也可双击执行