First page Back Continue Last page Overview Graphics

Various ways of Reading a File

fh = open('file')

read entire file into string:

fh.read( )

read next N bytes into string:

fh.read(N)

read entire file into list of lines:

fh.readlines( )

read next line, through '\n':

fh.readline( )