On 10/07/07, elis aeris <[EMAIL PROTECTED]> wrote:
> from the document i know that if I want to open a text file I do:
>
> f = open("text.txt", "r+")
>
> and thus create f as an file object i can then use.
>
> however, i don't understand these functions
>
> .readline
> .readlines
> .read
> .xlinesread

The best way to find out what the functions do is to experiment with them.

eg:

>>> f = open('text.txt', 'r')
>>> f.readlines()

and look at the output.

However, that said, the modern way to read a file one line at a time is:

f = open('text.txt', 'r')
for line in f:
    # do something with line

This will set the variable 'line' to each line of the file in turn.

-- 
John.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to