0

how to remove punctuations from a file crated using python

21st Nov 2016, 7:28 PM
Anju kv
Anju kv - avatar
3 odpowiedzi
0
def removePunctuation(text): t = text for p in '.,!?;:…': t = t.replace(p,'') return t
22nd Nov 2016, 12:39 AM
Udson Silva
Udson Silva - avatar
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
22nd Nov 2016, 1:29 AM
Agaba Ivan
Agaba Ivan - avatar
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)
22nd Nov 2016, 9:09 AM
Agaba Ivan
Agaba Ivan - avatar