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( )
文字列を返す

おすすめ

転載: www.cnblogs.com/yp19970/p/12743741.html