12 lines
345 B
Python
12 lines
345 B
Python
import xml.etree.ElementTree as ET
|
|
|
|
# 读取 XML 文件
|
|
tree = ET.parse('annotations.xml')
|
|
root = tree.getroot()
|
|
|
|
# 清空所有 polygon 的 points 属性
|
|
for polygon in root.iter('polygon'):
|
|
polygon.set('points', '')
|
|
|
|
# 保存回文件(或另存为新文件)
|
|
tree.write('annotations_cleared.xml', encoding='utf-8', xml_declaration=True) |