The big difference between Python 3 and 2 is that Python itself is replaced by the default Unicode encoding.
The string no longer distinguishes between "abc" and U "abc", the string "ABC" is Unicode by default and no longer represents the local encoding,
Because of this internal code, like C # and Java, there is no need to do similar set-up coding in the language environment, such as "sys.setdefaultencoding";
Also therefore Python 3 code and package management broke and 2.x compatible. The 2.x expansion pack is adapted to this situation.
Another problem is that only Unicode in the locale can output local encodings such as GBK.
It is customary to convert the cost to encode at (serialized) output.
Like what
| 1 |
file.write("GBK的中文".encode("GBK")) |
The strings in the Python environment are output to a byte string using the Str.encode ("GBK") method for communication with other environments.
Python 3 encoding