2012-09-10 95 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 –

回答