Python3 utf-8 解码问题

23 浏览
0 Comments

Python3 utf-8 解码问题

以下代码在我的Windows机器上使用Python3运行良好,并打印字符'é':

data = b"\xc3\xa9"
print(data.decode('utf-8'))

然而,在基于Ubuntu的Docker容器上运行相同代码会导致以下错误:

UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in position 0: ordinal not in range(128)

我需要安装什么才能启用utf-8解码?

0