# open file 'r' for read only # this assumes that myfile.txt is # in the current working directory theFile = open('myfile.txt', 'r') # iterate through the lines in the file object for line in theFile: # this is where you would perform logic on each line, or just print print line # close the file theFile.close() #output: # Line one is here # line two is here # line 3 is here!
A python example based blog that shows how to accomplish python goals and how to correct python errors.
Showing posts with label file. Show all posts
Showing posts with label file. Show all posts
Wednesday, June 24, 2009
python open and read through file
Subscribe to:
Posts (Atom)