sinat_29902953
sinat_29902953
2015-07-17 08:28

python调用xml文件的时候,报出ExpatError求大神指点

  • python
  • selenium
  • xml

问题代码:
import xml.dom.minidom
#打开xml文件
dom=xml.dom.minidom.parse("C:\Users\***\Desktop\myprogram\login.xml")

运行时,提示:
Traceback (most recent call last):
File "C:\Users***\Desktop\myprogram\test_login.py", line 9, in
dom=xml.dom.minidom.parse("C:\Users\***\Desktop\myprogram\login.xml", parser=None, bufsize=None)
File "C:\Python27\lib\xml\dom\minidom.py", line 1918, in parse
return expatbuilder.parse(file)
File "C:\Python27\lib\xml\dom\expatbuilder.py", line 924, in parse
result = builder.parseFile(fp)
File "C:\Python27\lib\xml\dom\expatbuilder.py", line 207, in parseFile
parser.Parse(buffer, 0)
ExpatError: not well-formed (invalid token): line 4, column 13

我的xml文件里有中文,这个不知道有没有影响,网上百度了一下,说是编码问题,就算是编码问题怎么解决啊,求大神赐教,小弟感激不尽...

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

5条回答

为你推荐