![](/img/trans.png)
[英]"string difference " - how to remove a certain substring from a string obtaining the rest
[英]how to remove certain substring from string in python?
a="<img src="hug.jpg/> India is a good country <img src="hug.jpg/> America is also good country "
所以我想這里是<img/>
標簽
In [104]: from bs4 import BeautifulSoup
In [105]: a="<img src=\"hug.jpg\"/> India is a good country <img src=\"hug.jpg\"/> America is also good country"
In [287]: soup = BeautifulSoup(a,"html.parser")
In [288]: soup.text
Out[288]: ' India is a good country America is also good country'
In [289]: soup.text.strip()
Out[289]: 'India is a good country America is also good country'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.