obj={"aa":3,"bb":[1,4,5,]} s=pickle.dumps(obj) print s newobj=pickle.loads(s) print newobj
f=open("test1.dat","w+") pickle.dump(obj,f) f.flush() f.seek(0) newobj=pickle.load(f) print newobj f.close()
obj={"aa":3,"bb":[1,4,5,]} data=shelve.open("testfile") data["obj"]=obj data.close()