Files\Python\lib\site-packages\elementtree\ElementTree.py",第960行,在 XML parser.feed(text)文件C :\Program 文件:\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ,0) ExpatError:未知编码:第1行,第30列 XML编码名称是否与Python不同? gbk编码似乎可以从Python中正常工作: open(filename).read()) Traceback (most recent call last): File "<interactive input>", line 1, in ? File "C:\Program Files\Python\lib\site-packages\elementtree\ElementTree.py", line 960, in XML parser.feed(text) File "C:\Program Files\Python\lib\site-packages\elementtree\ElementTree.py", line 1242, in feed self._parser.Parse(data, 0) ExpatError: unknown encoding: line 1, column 30 Are the XML encoding names different from the Python ones? The "gbk" encoding seems to work okay from Python: 我在cElementTree和cp1252编码方面遇到了类似的问题。但 升级到更新的版本有所帮助。您是否尝试使用例如 sax解析? Diez I had similar trouble with cElementTree and cp1252 encodings. Butupgrading to a more recent version helped. Did you try parsing with e.g.sax? Diez 这篇关于elementtree和gbk编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-12 23:00