how to call a text file

Chris Sprinkles sprinkles.chris at gmail.com
Fri May 9 16:13:43 EDT 2008


I need to know how to call a text file called txt_file.do I just put the
directory that it is in like C:\documnet\blah\blah ???

cars_file = open()

# i will be our line counter so we know when to pause
i = 0

print

for line in cars_file:

   i = i + 1      # increment i by 1 at each line

   print line

   if i == 5:    # change 5 to whatever you think is adequate

        i = 0      # zero the counter
        print
        raw_input("Hit Enter to continue: ") # wait for the user
        print

print
cars_file.close()
-Chris-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080509/7032671c/attachment.html>


More information about the Python-list mailing list