Mega Code Archive

 
Categories / Python / File
 

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()