python实现去除文本中的中文符号和英文符号
import re
line = line.decode("utf8")
string = re.sub("[\s+\.\!\/_,$%^*(+\"\']+|[+——!,。??、~@#¥%……&*()]+".decode("utf8"), "".decode("utf8"),line)
本文介绍了一种使用Python去除文本中的中文及英文符号的方法。通过正则表达式匹配各种符号并将其替换为空字符,实现了文本的初步清洗。
import re
line = line.decode("utf8")
string = re.sub("[\s+\.\!\/_,$%^*(+\"\']+|[+——!,。??、~@#¥%……&*()]+".decode("utf8"), "".decode("utf8"),line)
