0

有一个默认编码 -如何在 Python3 中默认'cp1251'更改为?UTF-8因为函数 sys.setdefaultencoding() 不起作用

4

1 回答 1

1

Python3str在 unicode 中不存在。如果您正在使用 bytearray 那么

mystring = b'my cp1251 byte array'.decode('cp1251')

您可以将其保留为 astr或将其放入 utf-8 字节数组:

my_utf_8_bytearray =  mystring.encode()
于 2015-11-06T17:44:23.257 回答