Pickling and shelving data : Pickle : Database PYTHON examples


PYTHON examples » Database » Pickle »

 

Pickling and shelving data





import cPickle, shelve

print "Pickling lists."
variety = ["sweet""hot""dill"]
shape = ["whole""spear""chip"]
brand = ["Claussen""Heinz""Vlassic"]
f = open("pickles1.dat""w")
cPickle.dump(variety, f)
cPickle.dump(shape, f)
cPickle.dump(brand, f)
f.close()

print "nUnpickling lists."
f = open("pickles1.dat""r")
variety = cPickle.load(f)
shape = cPickle.load(f)
brand = cPickle.load(f)
print variety, "n", shape, "n", brand
f.close()


           
       



Leave a Comment / Note


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


PYTHON examples

 Navioo Database
» Pickle