File types for Python

Source: Internet
Author: User

1.3.1 Source Code
Python source code with ". Py" as the extension, interpreted by the Python program, do not need to compile

1.3.2-byte code
The Python source file is compiled with a file extension of ". PYc", which provides a method for compiling the module
Import Py_compile
Py_compile.compile ("hello.py")
For example, we create a new "1.py" file, the code is as follows:

#!/usr/bin/pythonprint("Hello World !")

Then we create a new "2.py" file compiled 1.py, the code is as follows

#!/usr/bin/pythonimport py_compilepy_compile_compile("/root/test/1.py")

In the case of the python3.6 version, after executing 2.py, a file "1.cpython-36.pyc" with the extension ". PYc" will be generated under the sibling directory, with the following results:

[[email protected] test]# python __pycache__/1.cpython-36.pycHello World !

1.3.3 Optimization Code
The optimized source file, with the extension ". Pyo", has the following command:
Python-o-M Py_compile hello.py

1.4 Python variables
Variables can store values within a specified range, and values can be changed, and Python's next variable is a reference to a data, consisting of numbers, letters, and underscores.

1.5 Python data type
Just as the numeric value is not the same as the string "123", Python's data types also include numeric values, strings, lists, tuples, and dictionaries;
Numeric types include integer, long integer, floating point, and complex type.

Integer (int) is a range-qualified, generally "2 of the 31 square to the 32-square", the value of more than the type of the range is a long integer type (long);
The divisor and the divisor have a floating-point number, and the result is a floating-point number;
The plural type is the plural type with a "J" appended to the value;
The definition of a string can be single quotes, double quotes, and three quotation marks, in addition to the ability to define a string can also be used as a comment;

Note: Python 2 non-floating-point numbers have int and long types. The maximum value of type int cannot exceed Sys.maxint,python 3, there is only one integer type int, and in most cases it is much like a long integer in Python 2.

File types for Python

Related Article

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.