from bs4 import BeautifulSoup
def remove_html_tags(html):
soup = BeautifulSoup(html, 'html.parser')
text = soup.get_text()
return text
import re
def remove_html_tags(html):
clean = re.compile('<.*?>')
text = re.sub(clean, '', html)
return text
html = '<p>Hello, <strong>world</strong>!</p>'
text = remove_html_tags(html)
print(text) # 输出: Hello, world!