Python Coding Brief description

Source: Internet
Author: User
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

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.