Home >Backend Development >Python Tutorial >What is the suffix of python source files?

What is the suffix of python source files?

尚
Original
2020-01-09 16:49:1011972browse

What is the suffix of python source files?

The python source file suffix is ​​py.

Files with a py extension are Python source code files, which are interpreted by python.exe and can be run under the console. Can be read and written with a text editor.

File suffixes commonly used in Python:

pyc

The pyc extension is the compiled file of Python. It executes faster than py files and cannot be edited and viewed with text editing. So pyc files are often released instead of py files.

When Python is executed, it will first compile the source code in the py file into PyCodeObject and write it into the pyc file, and then the virtual machine will execute PyCodeObject.

When Python executes import, it will first look for the corresponding pyc or pyd (dll) file. If not, the corresponding py file will be compiled and written into the pyc file. pyc files can also be generated via python -m py_compile src.py.

pyw

The pyw file is similar to the pyc file, but the console window will not appear when pyw ​​is executed. When developing (pure graphical interface program), you can temporarily change pyw to py to bring up the console window for debugging.

pyo

pyo is an optimized and compiled program and cannot be edited with a text editor. python -O source.py can compile the source program into a pyo file.

pyd

pyd is generally a Python extension module written in other languages ​​other than Python, such as C/C, that is, a dynamic link library of Python, which is equivalent to a dll file. In Linux systems, it is generally a .so file

Manypython training videos, all on the python learning network, welcome to learn online!

The above is the detailed content of What is the suffix of python source files?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn