Python3, changed the default encoding, changed in order to Unicode
Prerequisite Knowledge:
- Utf-8 relationship to Unicode: Https://baike.baidu.com/item/UTF-8/481798?fr=aladdin
- The \x represents the hexadecimal data.
- Encode default is Utf-8, the right figure in the \x corresponding to the Unicode to UTF-8 encoded data:
- UTF-8: Use 1, 2, 3, 4 bytes for all characters, a priority of 1 characters, not enough to increase one byte, up to 4 bytes. English accounts for 1 bytes, European languages accounted for 2, East Asia accounted for 3, other and special characters accounted for 4
- Unicode has a large capacity, and almost all other encodings have mappings on them, such as the Chinese encoding method GBK
- , so the ' medium ' encoding in Unicode is 20013
Python3 STR is Unicode, used in binary, 16, and other formats bytes
Decode is to tell Unicode what you are coding:
The result of encode is a bytes object: a hexadecimal representation of the corresponding character's various encoding methods
The following is the result of encode in GBK format:
So the decode and encode are actually:
Encode (), decode () character encoding issues