Greg, You might try… Import sting delimiter = ‘.’ f = open('words.txt', "r") lines = f.readlines() for line in lines: line_items = string.split(line,delimiter)
From: tutor-bounces+jeffpeery=seametrics....@python.org [mailto:tutor-bounces+jeffpeery=seametrics....@python.org] On Behalf Of Greg Christian Sent: Wednesday, May 04, 2011 11:38 AM To: tutor@python.org Subject: [Tutor] Reading elements in a file 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
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor