my solution:
import re
infile = open('c:\\python26\\MyProgs\\inputfile.txt' , 'r')
instring = infile.read()
infile.close()
#find all non-word characters ...
p = re.compile('\W|_')
# ... and remove them from instring,
# so that only word characters are left in instring
print p.sub('', instring)
official solution
No comments:
Post a Comment