We mentioned in the previous section that using the Chinese full-width notation will give an error, so in this section, we'll explain Python's coding.
As we all know, the first computer in the world was developed by the United States, and Americans did not expect it to be spread all over the world, so their computer's default encoding format is ASCII.
Ascii
ASCII (American Standard Code for information Interchange, US Information Interchange standards codes) is a computer coding system based on the Latin alphabet, mainly used to display modern English and other Western European languages. It is now the most versatile single-byte encoding system and is equivalent to ISO/IEC 646.
By now, computers have been around the world, and in so many countries around the world, there will certainly be many languages, so ASCII has not been able to meet the needs of people. At this point, there is a Unicode encoding format that is compatible with multiple languages, that is, the universal code.
Unicode
Unicode (Uniform Code, universal Code, single Code) is an industry standard in the field of computer science, including character set, encoding scheme, etc. Unicode is created to address the limitations of traditional character encoding schemes, which set a uniform and unique binary encoding for each character in each language to meet the requirements of cross-language, cross-platform text conversion and processing. Research and development began in 1990, officially announced in 1994.
UTF-8UTF-8 (8-bit Unicode Transformation Format) is a variable-length character encoding for Unicode, also known as the Universal Code. Created by Ken Thompson in 1992. It is now standardized to RFC 3629. UTF-8 encodes Unicode characters in 1 to 6 bytes. Use on the Web page to display the Chinese simplified traditional and other languages (such as English, Japanese, Korean) on a unified page.
Utf-8 can be said to be an optimized version of Unicode.
We all know that a letter is 1 bytes, is a letter is 8 bits, and Unicode uses 16 bits to represent bytes, so even if you are not enough 16 bit it will be in front of you to fill 0 to fill 16 bits, which means that you write letters in Unicode will waste memory, and slow down the speed of running. And Utf-8, it is a kind of variable length encoding way. It can use 1~4 bytes to represent a symbol, varying the length of a byte depending on the symbol.
Python encoding format