About open file for Read

moonhkt moonhkt at gmail.com
Mon Dec 10 11:36:22 EST 2012


Hi All

I am new in Python. When using open and then for line in f .

Does it read all the data into f object ? or read line by line ?


  f=open(file, 'r')
           for line in f:
              if userstring in line:
                 print "file: " + os.path.join(root,file)
                 break
           f.close()


moonhk



More information about the Python-list mailing list