Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python remove punctuation from text file

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 
Comment

PREVIOUS NEXT
Code Example
Python :: remove punctuation python 
Python :: boto3 delete bucket object 
Python :: python iterate through files 
Python :: file searching in python 
Python :: get tail of dataframe pandas 
Python :: how to urllib3 
Python :: python send image in post request with json data 
Python :: python install jedi 
Python :: alphabet python 
Python :: finding the rows in a dataframe where column contains any of these values python 
Python :: from math import python 
Python :: get only every 2 rows pandas 
Python :: tensor get value 
Python :: python update multiple dictionary values 
Python :: how to run cmd line commands in python 
Python :: python Decompress gzip File 
Python :: dataframe to dictionary 
Python :: Converting objects into integers 
Python :: E: Unable to locate package python-gobject 
Python :: assign multiline string to variable in python 
Python :: python mean ndarray 
Python :: how to fill nan values in pandas 
Python :: python pdf fpdf example 
Python :: NumPy unique Example Get the counts of each unique value 
Python :: python no module named 
Python :: venv 
Python :: dataframe to dict without index 
Python :: python flatten array of arrays 
Python :: check all values in dictionary python 
Python :: python count code, Count number of occurrences of a given substring 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =