python remove punchuation code example
Example 1: remove punctuation from string python
#with re
import re
s = "string. With. Punctuation?"
s = re.sub(r'[^\w\s]','',s)
#without re
s = "string. With. Punctuation?"
s.translate(str.maketrans('', '', string.punctuation))
Example 2: clean punctuation from string python
s.translate(str.maketrans('', '', string.punctuation))