【发布时间】:2012-09-03 11:20:26
【问题描述】:
可能重复:
Convert XML/HTML Entities into Unicode String in Python
Decode HTML entities in Python string?
我正在使用 Python 2.7,并且在 unicode 类型中迷失了方向。我查找了各种帮助文件和教程,因为我无法让它在我需要的上下文中实际工作。 http://docs.python.org/howto/unicode.html
我有一个带有名称的库,它被解码保存,例如。亚伦的 我需要将名称编码为用户友好的方式 似乎是编码的基本答案
a ='aaron's,'
unicode(a)
a.encode('ascii', 'replace')
返回:
'aaron's,'
这不是我想要的。
【问题讨论】: