转换</br>到终点线 [英] Convert </br> to end line
本文介绍了转换</br>到终点线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用BeautifulSoup
提取一些文本.我为此使用get_text()
函数.
I'm trying to extract some text using BeautifulSoup
. I'm using get_text()
function for this purpose.
我的问题是文本包含</br>
标记,我需要将它们转换为结束行.我怎样才能做到这一点?
My problem is that the text contains </br>
tags and I need to convert them to end lines. how can I do this?
推荐答案
正则表达式可以解决问题.
A regex should do the trick.
import re
s = re.sub('<br\s*?>', '\n', yourTextHere)
希望这会有所帮助!
这篇关于转换</br>到终点线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文