
from lxml import etree
from lxml.html import tostring
html='我是666
'
content = etree.HTML(html).xpath('//p')[0]
# 获取当前标签的HTML源码
html = tostring(content, encoding="utf-8").decode("utf-8")
print(html)
输出结果:我是666
欢迎分享,转载请注明来源:内存溢出

from lxml import etree
from lxml.html import tostring
html='我是666
'
content = etree.HTML(html).xpath('//p')[0]
# 获取当前标签的HTML源码
html = tostring(content, encoding="utf-8").decode("utf-8")
print(html)
输出结果:我是666
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)