2013-01-06 33 views
0

我要解析一些XML输出(从某个网站的请求)像下面波纹管。他们部分用英语,部分用法语。我无法解码和打印(在屏幕上,文件上)法语口音,如'é'或'à'无法解码奇怪的Xml文件

当我使用decode('utf-8')时,出现错误结果,如'è'。我正在使用Python 3.3。

b'Extr\xc3\x83\xc2\xaamement fort et incroyablement pr\xc3\x83\xc2\xa8s</title><originaltitle>Extremely Loud And Incredibly Close</originaltitle><year>2011</year><runtime>0</runtime><directors><director>Stephen Daldry</director></directors><plot>Oskar Schell, 11 ans, est un jeune New-Yorkais \xc3\x83\xc2\xa0 l\'imagination d\xc3\x83\xc2\xa9bordante. Un an apr\xc3\x83\xc2\xa8s la...</plot></movie></results>\n' 
+0

您使用的是什么平台(操作系统)? –

+0

在Linux上工作(Ubuntu的) – Vincent

+0

你的意思是你最后的编辑似乎删除XML声明 - 但事实如此可读 – Mark

回答

5

您粘贴的字节串是双编码,

byteStrInYourQuestion.decode('utf-8').encode("ISO-8859-1").decode("utf-8") 

应该工作。

+0

它工作得很好!谢谢 ! – Vincent