赞
踩
pip install lxml
如有报错,具体安装教程请查看:http://Lxml.de/installation.html
from lxml import etree
#创建节点对象
root=etree.Element('p')
#添加子节点
sub1=etree.SunElement(root,'a')
#节点名
print(root.tag)
#节点对象的属性类似字典类型,可按字典进行操作
root.set('class','123')
root.get('class')
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。