1.Python Introduction
Python is a high-level language, equivalent to Java C #. You can write a variety of applications, each of which has its own appropriate application scenario. While Python
Has the advantage of being more user-friendly, easy-to-use grammar rules, and a code base that many predecessors have written for a variety of specific scenarios, so that programmers take advantage of Python
When developing, you can directly invoke the code written by predecessors and save more development time. Python itself is a program that Python will conform to Python
The code of the programming rules is converted into bytecode---machine code is provided to the CPU after processing.
2.Python vs. Other languages:
Python is a program, she is also by C, JAVA,. NET is written in a language like this. The C language was written by Cpython,
If it was written in Java, he would call Jpython, if it was Microsoft. NET is written so that he is called Irompython.
? CPython is a commonly used implementation version, which is written in C language. Her running logic is to convert the code into a C-byte code---machine code and then commit
CPU and memory for processing.
? PyPy is an efficient form of Python implementation that is written in the C language. Her running logic is to convert the code into a C-byte code---machine code and then
Submit CPU and memory for processing. She differs from CPython in that she converts all code into machine code at once, so that the hardware executes
No step-by-step transcoding process. But it takes a whole chunk of time for the code to be converted for the first time.
? Jpython is a Python implementation form written in Java, with code---Java Bytecode---machine code.
3.Python Foundation
python: python2.7 3.5 installed in the computer This is Python software and is also a Python interpreter.
interpreter: The interpreter's role is to judge the syntax of the Python code we have written. Finally converted to the final machine-readable machine code, final commit
Handle the hardware. Code---> Compiler---> Bytecode---> Machine code---> Hardware.
interpreter operating mode :
Windows Execution mode : Python interpreter path + code file. Interactive mode: go to the Python command line and enter it again and again
Code to execute.
Linux execution : You can make the. py code file Call the Python interpreter directly by adding an environment variable in the first line of the code. Head
Document Notation #! /usr/bin/python. The other is the same as Windows.
code file suffix name : general use. PY facilitates identification of non-coercion.
Coding
There may be multiple languages and characters in the code, so for this information we need to have corresponding coding rules and sets to interpret the words.
The corresponding relationship between the character and the underlying code. Otherwise, garbled characters will appear.
ASCII-American National Standard Code only supports English and certain characters, 1 bytes per character-8 bit--total can express 256 characters
For example, a with 01100001 means a with 01000001.
Universal Code Encoding-at least 16bit two bytes can be filled with 0 without 16bit. If it is Chinese then it needs 24 bits. 3 bytes
utf-8 is an optimization of the universal code, in bytes, either 8-bit or 16-bit or 24-bit. Chinese must be 24 bits, 3 bytes.
GBK GB2312 is a pure Chinese encoding library. Try not to use, for foreign words is not compatible. GB2312 more traditional characters than GBK.
Chinese requires only 2 bytes.
The default python2.x interpreter is performed by default in ASCII encoding. The PYTHON3.0X interpreter is executed by default in Utf-8 encoding.
Tells the interpreter what to do to perform the encoding recognition in the code file header plus #-*-CODING:GBK-*-or #-*-coding:utf-8-*-
Comments
Single-line Comment: Add # For example # print (' Hello World ') to the left of the characters you want to comment by Ctrl +? Number to quickly annotate and
Dismiss the comment.
Multiline Comment: Add "" "" "" "" "" "" "" "quotation mark to the characters that need to be commented, single and double quotation marks can be. "Shortcut key comment is invalid"
Python 1 initial Python code annotations