python 去除文本中的标点符号

直接上代码

import re

def removePunctuation(self, content):
        """
        文本去标点
        """
        punctuation = r"~!@#$%^&*()_+`{}|\[\]\:\";\-\\\='<>?,./,。、《》?;:‘“{【】}|、!@#¥%……&*()——+=-"
        content = re.sub(r'[{}]+'.format(punctuation), '', content)
        return content.strip().lower()

猜你喜欢

转载自blog.csdn.net/qq_40771567/article/details/114377239