为什么列表的unicode元素会被隐藏? [关闭]

问题描述 投票:-5回答:1

如果我想正确地将Unicode元素显示为字符串,我为什么要用英语?

string python-2.7 list selenium python-unicode
1个回答
2
投票

我想你可以将每个项目逐个编码成utf-8,如果这就是你想要的。

list = [u"hi",u"Whatever",u"Hello"]
map(lambda item: item.encode("utf-8"), list)

输出

['hi', 'Whatever', 'Hello']

有关the map function的更多详细信息,请参阅以下内容。如果这是一个选项,你也可以使用python3。

© www.soinside.com 2019 - 2024. All rights reserved.