from glob import glob pattern = \"D:\\\\report\\\\shakeall\\\\*.txt\" filelist = glob(pattern) def countwords(fp): with open(fp) as fh: return len(fh.rea
import re string = open('a.txt').read() new_str = re.sub('[^a-zA-Z0-9\n\.]', ' ', string) open('b.txt', 'w').write(new_str)
It will change every non alphanumeric char to white space.