繁体   English   中英

使用python查找html中的换行符

[英]Find break lines in html using python

我正在尝试找到所有换行符(br),而且在html网站的段落(p)中也要换行。 我有这个代码

breaks = re.findall('br<>\n', html)
print len(breaks)

但它不起作用。 任何帮助

我不确定您要什么,因为您没有显示示例输入和输出。

但是,如果您希望在<br>标记或换行符之后进行拆分,则可以尝试以下操作:

# included many vairations of the '<br>' tag
breaks = re.findall('<br>|<br/>|<br />|\n', html)
print len(breaks)

有帮助吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM