开发者

lxml Changing Unicode Characters

I am using lxml to read through an xml file and change a few details. However, when running it I find that even if I just use lxml to read the file and then write it out again, as below:

fil='iTunes Music Library.XML'
tre=etree.parse(fil)
tre.write('temp.xml')

I find Quee开发者_JAVA百科nsrÿche converted to Queensrÿche. Anyone know how to fix this?


Change your last line to:

tre.write('temp.xml', encoding='utf-8')

Otherwise lxml writes XML in ASCII encoding, so it have to escape all non-ASCII characters.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜