0
how to remove punctuations from a file crated using python
3 odpowiedzi
0
def removePunctuation(text):
t = text
for p in '.,!?;:…':
t = t.replace(p,'')
return t
0
Make sure the statement is string
you can then use methods like strip(to remove beginning and ending punctuation )
you can then split the string making it a list and remove the punctuation in between sentences then after convert it back to a string
0
//code
s = "0000000this is string example....wow!!!0000000";
x=s.strip("0")
print(x)
y=x.strip("!")
print(y)
w=y.split(".")
print(w)
str1=" ".join(str(e).strip() for e in w)
print (str1)