how to dump and load file in python code example
Example 1: write data to using pickle
import pickle
example_dict = {1:"6",2:"2",3:"f"}
pickle_out = open("dict.pickle","wb")
pickle.dump(example_dict, pickle_out)
pickle_out.close()
Example 2: load from file pickle
1 # Load the dictionary back from the pickle file.
2 import pickle
3
4 favorite_color = pickle.load( open( "save.p", "rb" ) )
5 # favorite_color is now { "lion": "yellow", "kitty": "red" }