Posted By

magicrebirth on 12/22/09


Tagged

python dictionary pickle


Versions (?)

Python: using Pickle to save a dictionary


 / Published in: Python
 

  1. import pickle
  2.  
  3. zoit = { "Crud": "No", "Fsck": "Blox"}
  4. file = open("pickle.pck", "w") # write mode
  5. pickle.dump(zoit, file)
  6.  
  7. print "Written to disk. Deleting 'zoit' now."
  8. del zoit
  9. file.close()
  10. del file
  11. print "Zoit is now deleted. Reading back from file now:"
  12.  
  13. file = open("pickle.pck", "r") # read mode
  14. narf = pickle.load(file)
  15. print narf

Report this snippet  

You need to login to post a comment.