Use Pickle to save and read
import pickle
dFile = open("storage.dat", "wb")
x = 123.467
pickle.dump( x,dFile )
y = 10
pickle.dump( y,dFile )
z = { 1 : "Hello", 2 : "Goodbye" }
pickle.dump( z, dFile )
dFile.close()
iFile = open("storage.dat", "rb" )
d1 = pickle.load(iFile)
print d1
d2 = pickle.load(iFile)
print d2
d3 = pickle.load(iFile)
print d3
iFile.close()
print "Done"
Related examples in the same category