This article mainly introduces Python's method of removing all HTML tags, involving Python regular substitution techniques, very simple and practical, the need for friends can refer to the
The examples in this article describe how Python removes all HTML tags. Share to everyone for your reference. The specific analysis is as follows:
This code can be used to remove the string tags in the text, excluding the contents of the tag.
|1 2 3 4 5||Import re html= ' <a href= "http://www.3lian.net" > Script Home </a>,python Learning! ' Dr = Re.compile (R ' <[^>]+> ', re. S) dd = dr.sub (', HTML) print (DD)|
The results of the operation are as follows:
|1||Scripting House, Python learning!|
I hope this article will help you with your Python programming.