关于#python#的问题:我没有找到办法可以在子节点的指定位置插入节点, 默认会插入到 asset 节点后面, 但我想插入到cmos节点后面, 虽然不影响读取

问题遇到的现象和发生背景

使用 python xml.etree.ElementTree 添加节点时

原xml

<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);

我已经解决了问题, 但还是感谢你给的提示