相关疑难解决方法(0)

从Unicode格式的字符串中删除标点符号

我有一个函数,从字符串列表中删除标点符号:

def strip_punctuation(input):
    x = 0
    for word in input:
        input[x] = re.sub(r'[^A-Za-z0-9 ]', "", input[x])
        x += 1
    return input
Run Code Online (Sandbox Code Playgroud)

我最近修改了我的脚本以使用Unicode字符串,所以我可以处理其他非西方字符.当遇到这些特殊字符并且只返回空的Unicode字符串时,此函数会中断.如何从Unicode格式的字符串中可靠地删除标点符号?

python unicode

40
推荐指数
4
解决办法
2万
查看次数

标签 统计

python ×1

unicode ×1