解析XML异常

Rex*_*unt 2 python xml parsing module elementtree

我是python的新手,非常需要帮助!我有一些我无法弄清楚的错误.我在mac上使用python 2.7.以下是错误列表:

Traceback (most recent call last):
  File "minihiveosc.py", line 378, in <module>
    swhive = SWMiniHiveOSC( options.host, options.hport, options.ip, options.port, options.minibees, options.serial, options.baudrate, options.config, [1,options.minibees], options.verbose, options.apimode )
  File "minihiveosc.py", line 280, in __init__
    self.hive.load_from_file( config )
  File "/Users/Puffin/Documents/python/pydon/pydon/pydonhive.py", line 396, in load_from_file
    hiveconf = cfgfile.read_file( filename )
  File "/Users/Puffin/Documents/python/pydon/pydon/minibeexml.py", line 116, in read_file
    tree = ET.parse( filename )
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 1183, in parse
    tree.parse(source, parser)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 656, in parse
    parser.feed(data)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 1643, in feed
    self._raiseerror(v)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 1507, in _raiseerror
    raise err
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 164, column 8
Run Code Online (Sandbox Code Playgroud)

有人可以帮我吗?谢谢!

Mar*_*ers 5

您在问题中发布的内容称为"Traceback",它只显示一个错误:

xml.etree.ElementTree.ParseError:格式不正确(令牌无效):第164行,第8列

之前的所有行都显示了python是如何到达那里的; 在文件中minihiveosc.py,在第378行执行了一些代码(显示在追溯中),然后导致相同文件的第280行,其中调用了其他内容,等等.

每次Python调用一个函数时,当前状态都会被压入堆栈,为下一个上下文腾出空间,当发生异常时,python可以显示这个堆栈来帮助你诊断问题

在这种情况下,您尝试将XML文档提供给其中包含错误的XML解析器; 当解析器到达第164行第8列时,它发现了一些它没想到的东西.您需要检查该文档以查看问题所在,它将围绕该区域.