Open a file and read a line : Text File Read Write : File PYTHON examples


PYTHON examples » File » Text File Read Write »

 

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



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo File
» Text File Read Write