How to Remove Punctuation From Text with Python

Python

 1|  import string
 2|  
 3|  text = 'This +text.. has some /punctuation'
 4|  mapping = str.maketrans('', '', string.punctuation)
 5|  text = text.translate(mapping)
 6|  
 7|  >> 'This text has some punctuation'
Did you find this snippet useful?

Sign up for free to to add this to your code library