我是 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
有人可以帮助我吗? 谢谢!
最佳答案
您在问题中发布的内容称为“回溯”,它仅显示一个错误:
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 164, column 8
它之前的所有行都显示了 python 是如何到达那里的;在文件 minihiveosc.py
中,在第 378 行执行了一些代码(在回溯中显示),然后导致同一文件的第 280 行,其中调用了其他内容,等等。
每次 Python 调用一个函数时,当前状态都会被压入堆栈,为下一个上下文腾出空间,当发生异常时,python 可以向您显示此堆栈以帮助您诊断问题
在这种情况下,您试图将一个 XML 文档提供给其中有错误的 XML 解析器;当解析器到达第 164 行第 8 列时,它发现了一些它没有预料到的东西。您需要检查该文档以查看问题出在哪里,它就在那个区域附近。
关于python - 解析 XML 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11280958/