def strip_tags(html):"""Python中过滤HTML标签的函数>>> str_text=strip_tags("<font color=red>hello</font>")>>> print str_texthello"""from HTMLParser import HTMLParserhtml = html.strip()html = html.strip("\n")result = []parser = HTMLParser()parser.handle_data = result.appendparser.feed(html)parser.close()return ''.join(result)
python 去除html标签函数
最新推荐文章于 2022-06-18 20:59:13 发布