Open a file and read a line : Text File Read Write « File « Python






Open a file and read a line

Open a file and read a line

myfile = open('myfile', 'r')             # open for input

print myfile.readline()                        # read the line back

print myfile.readline()                        # empty string: end of file

myfile.close()
           
       








Related examples in the same category

1.Open a text file and write a line of text