美文网首页
Python3 使用ElementTree 找到xml中的标签进

Python3 使用ElementTree 找到xml中的标签进

作者: ElonYanJ | 来源:发表于2018-11-19 11:49 被阅读9次
import xml.etree.ElementTree as ET

color_xml = ori + "app/src/main/res/values/colors.xml"
updateTree = ET.parse(color_xml)
root = updateTree.getroot()

for child in root:
    for key in color_value_map:
        if child.attrib['name'] == key:
            child.text = color_value_map[key]

updateTree.write(color_xml)

相关文章

网友评论

      本文标题:Python3 使用ElementTree 找到xml中的标签进

      本文链接:https://www.haomeiwen.com/subject/kqvofqtx.html