import re
import sys
punctuation = "~!@#$%^&*()_+`{}|\[\]\:\";\-\\\='<>?,./?,。;!~"
def removePunctuation(text):
text = re.sub(r'[{}]+'.format(punctuation), ' ', text)
return text.strip().lower()
for line in sys.stdin:
line = line.replace("\n", "")
replaced_line = removePunctuation(line)
print(replaced_line)
[linux] 正则re去除标点符号等自定义特殊字符
猜你喜欢
转载自blog.csdn.net/Trance95/article/details/130198469
今日推荐
周排行