[Tutor] Reading elements in a file
Greg Christian
glchristian at comcast.net
Wed May 4 20:40:08 CEST 2011
Python version = 2.7.1
Platform = win32
I am kind of stuck on what is probably a simple thing:
If we have a file of words like this: “first”,”word”,”in”,”that”,”another”,”part”,”of”,”this”
f = open('words.txt', "r")
words = f.read()
will read the whole file, is there a way to read just the words: first word in that another part of this
I guess I have to separate on the “,” but I am not quite sure how to go about this.
Any input would be appreciated.
Regards,
Greg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110504/ecb92fa1/attachment.html>
More information about the Tutor
mailing list