Python 执行过程 和 文件类型


1. python文件的执行过程:

hello.py --> python解释器 -->  字节码文件(能被python解释器识别,不能被计算机识别)--> python解释器 --> 二进制文件 --> 内存(运行)--> 打印结果

Python 执行过程 和 文件类型_第1张图片




2.字节码文件分为

python和java类似,都是编译出字节码文件再执行
.pyc(生成方法:python -m py_compile hello.py),.pyo(生成方法:python -O -m py_compile hello.py),pyc文件可以被直接执行且能提升加载效率,但不能提升运行效率,pyo文件是优化编译的pyc文件。可直接使用python命令执行上述两个文件(python hello.pyc)、(python hello.pyo)


你可能感兴趣的:(Python)