Use
Python-m Py_compile file.py
Python-m py_compile/root/src/{file1,file2}.py
Compiled into a pyc file.
You can also write a script to do the job:
Code:
Import Py_compile
Py_compile.compile (' path ')//path is the path that includes the. py file name
Use
Python-o-M Py_compile file.py
Compiled into a pyo file.
1. The-M is equivalent to the import in the script, where the-M py_compile is equivalent to the import py_compile
2.-o If you change to-oo is to delete the corresponding pyo file, specific help can be entered in the console python-h view
What is a PYc file
PYC is a binary file, which is generated by the py file after compiling, is a byte code,py file becomes PYc file, the speed of loading is increased, and PYC is a cross-platform bytecode, is executed by Python virtual machine, This is the concept of a virtual machine similar to Java or. Net. PYC content, is related to Python version, the different version of the compiled PYc file is different, 2.5 compiled PYC files, 2.4 version of Python is not executable.
What is a pyo file
PYO is an optimized compiled program Python-o source file to compile the source program into a pyo file
What is a PYD file
PYD is a dynamic link library for Python.
Under Python compile py into PYc and PYO