如何删除< BR>使用替换功能? [英] how to remove <BR> using replace function?

查看:114
本文介绍了如何删除< BR>使用替换功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些看起来像这样的HTML

< address style =" color:#"> 34 main,< br>波士顿,马萨诸塞州< / address>


我试图使用替换功能来摆脱< br>那个

i使用这段代码:


for fact.fetchText(oRE)中的oText:

strTitle + = oText。 strip()

strTitle = string.replace(strTitle,''< br>'','''')


但它没有'''似乎删除了< br>

任何想法?

i have some html that looks like this
<address style="color:#">34 main,<br> Boston, MA</address>

and i am trying to use the replace function to get rid of the <Br> that
i scrape out using this code:

for oText in incident.fetchText( oRE):
strTitle += oText.strip()
strTitle = string.replace(strTitle,''<br>'','''')

but it doesn''t seem to remove the <br>

any ideas?

推荐答案

I我想你想使用字符串实例的替换方法。

这样的东西会起作用:


#参见 http://docs.python.org/lib/string-methods.html#l2h-196

txt =" a unfortunate< br>在中间

txt = txt.replace("< br>","")

I think you want to use the replace method of the string instance.
Something like this will work:

# See http://docs.python.org/lib/string-methods.html#l2h-196
txt = "an unfortunate <br> in the middle"
txt = txt.replace("<br>", "")


尝试过,对我不起作用

tried that, didn''t work for me


nope不起作用

nope didn''t work


这篇关于如何删除&lt; BR&gt;使用替换功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆