【问题标题】:Unicode encoding in python [duplicate]python中的Unicode编码[重复]
【发布时间】: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,'

这不是我想要的。

【问题讨论】:

标签: python unicode


【解决方案1】:

您正在寻找 HTML 实体解码,而不是 Unicode(或编解码器)解码。

请参阅Decode HTML entities in Python string? 了解执行此操作的方法。

【讨论】:

    猜你喜欢
    • 2013-05-11
    • 1970-01-01
    • 2019-12-19
    • 2012-04-10
    • 2020-01-27
    • 1970-01-01
    • 1970-01-01
    • 2011-03-14
    • 2013-09-10
    相关资源
    最近更新 更多