[Python] python 清除html标签函数 →→→→→进入此内容的聊天室

来自 , 2020-08-19, 写在 Python, 查看 186 次.
URL http://www.code666.cn/view/a01dfc71
  1. def stripTags(s):
  2.     ''' Strips HTML tags.
  3.        Taken from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440481
  4.    '''
  5.     intag = [False]
  6.    
  7.     def chk(c):
  8.         if intag[0]:
  9.             intag[0] = (c != '>')
  10.             return False
  11.         elif c == '<':
  12.             intag[0] = True
  13.             return False
  14.         return True
  15.    
  16.     return ''.join(c for c in s if chk(c))
  17. #//python/1882

回复 "python 清除html标签函数"

这儿你可以回复上面这条便签

captcha