Looping Over Characters with read Writing the Loop Differently : File Write « File « Python






Looping Over Characters with read Writing the Loop Differently

 

f = open("filename")
while 1:
    char = f.read(1)
    if not char: break
    process(char)
    
f.close()    

           
         
  








Related examples in the same category

1.Writing to FilesWriting to Files
2.File writelines(list)
3.File write(string)
4.File Output
5.Writes the contents of string to the file