Python 3打印UnicodeEncodeError

时间:2018-08-22 01:59:07

标签: python unicode

如何在Python中完全像一样打印(unicode u2019)?注意:我知道如果我做print(text_bytes)会得到b'’',这不是我想要的,只是。在Windows 10上使用python 3.5.3版。

代码:

text = '’'
text_bytes = text.encode('utf-8')
text_str = str(text_bytes, 'utf-8')
print(text_str)

结果:

File "C:\Python\Python35\lib\encodings\cp850.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2019' in position 0: character maps to <undefined>

0 个答案:

没有答案