我正在使用ElementTree.parse函数解析用utf-16编码的xml文件。当文件包含一些格式不正确的字符(如♀, ♂、.etc )时,程序将崩溃。并出现错误“xml.parsers.expat.ExpatError: not well-formed (invalid token)”。如何避免此错误并解决此问题?我怎么能忽略这些格式不正确的字符呢?谢谢!下面是我的代码:
tree = ElementTree(
local/master/hue/desktop/libs/hadoop/src/hadoop/confparse.py", line 44, in __init__xml.parsers.expat.ExpatErrorlocal/master/hue/desktop/libs/hadoop/src/hadoop/confparse.py", line 44
How do I get Python's ElementTree to pretty print to an XML file? 但是我有一个我不理解的错误。minidom.parseString(ET.tostring(root).decode("utf-8")).toprettyxml(indent=" ")
File "/usr/lib/python3.6/xmlminidom.py", line 1968, in pa
我正在尝试使用Python读取HDFS目录中的文件。我使用了下面的代码,但我得到了错误。/xml/etree/ElementTree.py", line 587, in parsexml.parsers.expat.ExpatError: no element found: line 1, column 0我的hdfs目录中有10-15个x
我正在尝试使用Element模块,但最终导致了一些我无法理解的错误。这里的代码是基于Python本身,,它在试图运行脚本时给了我一个错误; import xml.etree.cElementTree as ETfile_name_xml = "curl-result.xml"
tree = ET.parse(file_name_xml