ide - python3编码问题
PHP中文网
PHP中文网 2017-04-18 09:37:33
0
2
380
PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
阿神

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………………

str.str.encode(编码格式) --> bytes
就是从 unicode 转换成 指定编码格式bytesen

code (encoding format) --> bytes

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"

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template