从 Python 中的字符串中去除标点符号

Strip Punctuation From String in Python

我正在处理文档,我需要在没有标点符号的情况下隔离单词。我知道如何使用 string.split(" ") 使每个单词只是字母,但标点符号让我感到困惑。

这是一个使用正则表达式的例子,结果是 ['this', 'is', 'a', 'string', 'with', 'punctuation']

s = " ,this ?is a string! with punctuation. "
import re
pattern = re.compile('\w+')
result = pattern.findall(s)
print(result)