Posted By

qrist0ph on 05/13/08


Tagged

file io cheatSheet


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

qrist0ph
taboularasa


Python File manipulation Cheat Sheet


 / Published in: Python
 

  1. #write to file
  2. f = open('c:/temp/workfile','w')
  3. f.write('hallo')
  4. f.close
  5.  
  6. #open from file
  7. f = open('file.txt')
  8.  
  9. #read linewise
  10. for i in f:
  11. print i
  12.  
  13. #read characterwise
  14. for i in f.read():
  15. print i

Report this snippet  

You need to login to post a comment.