使用 python xml.etree.ElementTree 添加节点时
<root>
<cmos>
W10
cmos>
<asset>
1.0.01
asset>
root>
<root>
<cmos>
W10
cmos>
<coms>
W11
cmos>
<asset>
1.0.01
asset>
root>
我没有找到办法可以在子节点的指定位置插入节点, 默认会插入到 asset 节点后面, 但我想插入到cmos节点后面, 虽然不影响读取
使用Element .insert()
方法rootElement.insert(1, subelement);
我已经解决了问题, 但还是感谢你给的提示