【问题标题】:TypeError: unbound method parse() must be called with ElementTree instance as first argument (got str instance instead)TypeError:必须使用 ElementTree 实例作为第一个参数调用未绑定的方法 parse()(改为获取 str 实例)
【发布时间】:2018-06-13 12:46:36
【问题描述】:

我正在尝试编辑一个 xml 文件。但是在执行下面提到的代码时,它显示一个错误“TypeError: unbound method parse() must be called with ElementTree instance as the first argument (got str instance)”。我的最后期限即将到来,任何帮助将不胜感激

from xml.etree.ElementTree import ElementTree as ET

tree = ET.parse('lolo.xml')

【问题讨论】:

  • 尝试将您的导入更改为import xml.etree.ElementTree as ET
  • 成功了。谢谢

标签: python-2.7 lxml elementtree


【解决方案1】:

添加评论作为答案...

尝试将您的导入更改为import xml.etree.ElementTree as ET

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-18
    • 2023-04-06
    • 1970-01-01
    • 2017-12-09
    • 2015-12-01
    • 2018-08-12
    相关资源
    最近更新 更多