Python file type

Source: Internet
Author: User
The following is a brief introduction to Python file types. I think this is quite good. now I will share it with you and give you a reference. Let's take a look at Python's file types in three ways: source file, byte-code file, and optimized file ). These codes can be run directly without compilation or connection. This is the feature of the pythonlanguage. the pythonfile is interpreted and run through python.exeand pythonw.exe.

1. source code

The Python source file uses "py" as the extension name, which can be run in the console as explained by python.exe. "Pyw" is the extension name of the graphic development user interface (gui.pdf file for desktop applications. This file is used in the graphic interface and is interpreted and run by pythonw.exe.

"Py" and "pyw" files can be opened and edited in a text editor.

2. byte code

After the Python source file is compiled, the extension "pyc" is generated. the file cannot be opened or edited in a text editor. The "pyc" file has nothing to do with the platform. Therefore, Python programs can run on Windows, Unix, Linux, and other systems.

Run the script to compile the "py" file into a "pyc" file.

Import py_compile2 py_compile.compile ("hello. py ")

After running the command, you can get the "hello. pyc" file, which is stored under _ pycache _ in the source file path. See https://www.python.org/dev/peps/pep-3147/

Run:

The above discussion about the Python file type is all the content shared by the small editor. I hope you can give me a reference and support PHP.

For more articles about Python file types, refer to PHP Chinese network!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.