Live2D

Python清除常见的网页空格格式

def clean(string):
pattern = re.compile(r'<[^>]+>', re.S)
string = pattern.sub('', string)
string = string.replace('\n', ' ').replace('\r', ' ').replace('&nbsp;', ' ').replace('\t', ' ').replace(" ",'')
string = string.strip()
return string
posted @ 2020-04-21 12:28  鸟-叔  阅读(576)  评论(0编辑  收藏  举报