Python2 default encoding: ASCII encoding is displayed correctly, program requires encoding conversion: UTF-8-->decode decode--unicodeunicode--> Encode code--> Gbk/utf-8 Pytho N3 default file Encoding: Utf-8 (interpreter encoding) Python3 in memory: All is the process of Unicodepython3 code execution: 1. The interpreter finds the code file, loads the code string into memory according to the encoding defined by the file header, turns into Unicode2, The code string is interpreted according to the Python syntax rule 3, all variable characters are declared in Unicode encoding ※windows's default encoding is GBK. Python2 file encoding default: ASCII string encoding default: ASCII if the file header declares Utf-8, that string encoding is utf-8 python3 file encoding default: Utf-8 string Encoding: Unicode file header: Python2: UTF -8 or GBK encoded code, the contents of the code are loaded into memory and will not be converted to Unicode, and the encoding remains utf-8 or GBK. Python3: Code encoded with Utf-8 or GBK, the contents of which are added to the memory, are automatically converted to Unicode. Common coding errors are: 1, the Python interpreter default encoding 2, the Python source file encoding 3, the terminal using the Encoding (Windows/linux/os) 4, the operating system language Settings ※unicode and GBK Mapping table:/HTTP www.unicode.org/charts/
Python Coding Brief description