linux:python:xml.etree.elementtree使用
差别
这里会显示出您选择的修订版和当前版本之间的差别。
| 两侧同时换到之前的修订记录前一修订版 | |||
| linux:python:xml.etree.elementtree使用 [2026/10/13 22:06] – 外部编辑 127.0.0.1 | linux:python:xml.etree.elementtree使用 [2026/10/13 22:51] (当前版本) – 外部编辑 127.0.0.1 | ||
|---|---|---|---|
| 行 3: | 行 3: | ||
| 有3种方法: | 有3种方法: | ||
| - | < | + | |
| + | ```python | ||
| import xml.etree.ElementTree as ET | import xml.etree.ElementTree as ET | ||
| 行 20: | 行 21: | ||
| fbuf = fh.read() | fbuf = fh.read() | ||
| root = ET.fromstring(fbuf) | root = ET.fromstring(fbuf) | ||
| + | ``` | ||
| - | </ | ||
| ## - 获取attrib | ## - 获取attrib | ||
| - | < | + | |
| + | ```python | ||
| name = root.attrib[' | name = root.attrib[' | ||
| - | </ | + | ``` |
linux/python/xml.etree.elementtree使用.1791900372.txt.gz · 最后更改: 由 127.0.0.1
