Python3 is improved to avoid encoding format confusion. By default, it reads and writes files in UTF-8 encoding format. There is no need to specifically specify utf-8.
In
python3, only byte objects in unicode encoding format can become str。 其他编码格式的是bytes, such as: gbk, utf-8………………
is the bytes converted from unicode to the specified bytes.decode(编码格式) --> str 就是从 指定编码格式的bytes 转换成 unicode 的strencoding format
bytes.str了,不必转成bytesde
code (encoding format) --> str 🎜 is to convert from bytes in the specified 🎜encoding format🎜 to unicode str 🎜
🎜print('Hello') 🎜'Hello' is already 🎜, just output it directly. 🎜
There are only unicode encoding and str in python3. Encode is to encode the string into unicode (that is what you see and think is strange), and decode is to decode the unicode encoding into a string. Print just accepts a string directly. Use print('Hello') to output "Hello"
Python3 is improved to avoid encoding format confusion. By default, it reads and writes files in UTF-8 encoding format. There is no need to specifically specify utf-8.
Inpython3, only byte objects in unicode encoding format can become
str
。其他编码格式的是
bytes
, such as: gbk, utf-8………………
code (encoding format) -->str
.str
.encode(编码格式) -->bytes
就是从 unicode 转换成 指定编码格式 的
bytes
enbytes
is the
bytes
converted from unicode to the specifiedbytes
.decode(编码格式) -->str
就是从 指定编码格式的
bytes
转换成 unicode 的str
encoding formatbytes
.str
了,不必转成bytes
destr
🎜 is to convert frombytes
in the specified 🎜encoding format🎜 to unicodestr
🎜 🎜print('Hello') 🎜'Hello' is already 🎜, just output it directly. 🎜There are only unicode encoding and str in python3. Encode is to encode the string into unicode (that is what you see and think is strange), and decode is to decode the unicode encoding into a string. Print just accepts a string directly. Use print('Hello') to output "Hello"