1import pickle #credits to stack overflow user= blender
2
3a = {'hello': 'world'}
4
5with open('filename.pkl', 'wb') as handle:
6 pickle.dump(a, handle, protocol=pickle.HIGHEST_PROTOCOL)
7
8with open('filename.pkl', 'rb') as handle:
9 b = pickle.load(handle)
10
11print (a == b)
1import pickle
2
3pickle.dump( favorite_color, open( "save.p", "wb" ) )
4favorite_color = pickle.load( open( "save.p", "rb" ) )
1import pickle
2with open('Fruits.obj', 'wb') as fp:
3 pickle.dump(banana, fp)
4
1import pickle
2file_name='my_file.pkl'
3f = open(file_name,'wb')
4pickle.dump(my_data,f)
5f.close()
1import pickle
2# load : get the data from file
3data = pickle.load(open(file_path, "rb"))
4# loads : get the data from var
5data = pickle.load(var)
1with open('mypickle.pickle', 'wb') as f:
2 pickle.dump(some_obj, f)
3
4# note that this will overwrite any existing file
5# in the current working directory called 'mypickle.pickle'
6