2012-09-10 94 views
2

可能重复:
Convert XML/HTML Entities into Unicode String in Python
Decode HTML entities in Python string?Unicode编码在Python

我使用Python 2.7和Unicode的类型是相当丢失。我查了很多帮助文件和教程,我无法在需要的上下文中找到它。 http://docs.python.org/howto/unicode.html

我有一个库的名称,它被保存解码,前。亚伦'小号 我需要的名字编码成一个用户友好的方式 好像基本答案编码

a ='aaron's,' 
unicode(a) 
a.encode('ascii', 'replace') 

回报:

'aaron's,' 

这是不是我所期待的。

+0

见 - http://stackoverflow.com/questions/57708/convert-xml-html-entities-into-unicode-string-in-python - http://stackoverflow.com/questions/701704 /怎么办 - 你 - 转换 - HTML实体对Unicode的和反之亦然式的Python –

回答