Horje
remove punctuation from string python Code Example
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))
Removing punctuation in Python
import string 
from nltk.tokenize import word_tokenize
s =  set(string.punctuation)          # !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
sentence = "Hey guys !, How are 'you' ?"
sentence = word_tokenize(sentence)
filtered_word = []
for i in sentence:
    if i not in s:
        filtered_word.append(i);
for word in filtered_word:
  print(word,end = " ")
python3 strip punctuation from string
import string
#make translator object
translator=str.maketrans('','',string.punctuation)
string_name=string_name.translate(translator)
clean punctuation from string python
s.translate(str.maketrans('', '', string.punctuation))
python remove punctuation
import string 
sentence = "Hey guys !, How are 'you' ?"
no_punc_txt = ""
for char in sentence:
   if char not in string.punctuation:
       no_punc_txt = no_punc_txt + char
print(no_punc_txt);                 # Hey guys  How are you 
# or:
no_punc_txt = sentence.translate(sentence.maketrans('', '', string.punctuation))
print(no_punc_txt);                 # Hey guys  How are you 
Python remove punctuation from a string
# Python program to remove punctuation from a string

import string
text= 'Hello, W_orl$d#!'

# Using translate method
print(text.translate(str.maketrans('', '', string.punctuation)))




Python

Related
auto clicker in python Code Example auto clicker in python Code Example
get files in directory python Code Example get files in directory python Code Example
set window size tkinter Code Example set window size tkinter Code Example
python flask query params Code Example python flask query params Code Example
ls.ProgrammingError: permission denied for table django_migrations Code Example ls.ProgrammingError: permission denied for table django_migrations Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
6