reading a line in file

Shawn Milochik Shawn at Milochik.com
Mon Aug 20 13:29:48 EDT 2007


Write some code, even if it doesn't quite work, and post it. We'll
help you fix it.

You can open a file with:  input = open("file.txt", "r")

You can read a line with: someText = input.readline()

You can loop through an open file like this:

for line in input:
    #do something with line


That should get you started.



More information about the Python-list mailing list