阅读背景:

lxml.etree 教程2: Elements are lists

来源:互联网 
>>> child = root[0]
>>> print(child.tag)
child1

>>> print(len(root))
3

>>> root.index(root[1]) # lxml.etree only!
1

>>> children = list(root)

>>> for child in root:
...     print(child.tag)
child1
child2
child3

>>> root.insert(0, etree.Element("child0"))
>>> start = root[:1]
>>> end   = root[-1:]

>>> print(start[0].tag)
child0
>>> print(end[0].tag)
child3
>>> child = root[0]
>>> print(child.tag)
ch



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: