10 examples of 'pickle save dictionary' in Python

Every line of 'pickle save dictionary' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
36def savepickle(dct):
37 """ Save settings dict to the pickle file """
38 with open('h5config.pkl','wb') as f:
39 pickle.dump(dct, f, protocol=0)
26def pickle(filename, data):
27 fo = filename
28 if type(filename) == str:
29 fo = open(filename, "w")
30
31 with fo:
32 cPickle.dump(data, fo, protocol=cPickle.HIGHEST_PROTOCOL)
105def save_pickle(filename, data):
106
107 file = open(filename + '.pck', 'w')
108 pickle_dump(data, file)
109 file.close()
110
111 return
43def PickleSave(file_name, data):
44 with open(file_name, "wb") as f:
45 pickle.dump(data, f, protocol=pickle.HIGHEST_PROTOCOL)
44def pickle_save(file_name, data):
45 with open(file_name, 'wb') as f:
46 pickle.dump(data, f, protocol=pickle.HIGHEST_PROTOCOL)
26def save(dir_path):
27 with open('%s/config/config.pkl' % dir_path,'w') as f:
28 pickle.dump(dict(bg=bg,
29 LH=LH,
30 LW=LW,
31 ), f)
114def load_dump(pickle_file):
115 with open(pickle_file, 'rb') as f:
116 data = pickle.load(f, encoding='bytes')
117 return data
86def save(filename):
87 import cPickle as pickle
88 with open('data/saves/%s' % filename,'w') as f:
89 pickle.dump(dict(bgL=bgL, bgR=bgR), f)
55def pickle_dict(items):
56 '''Returns a new dictionary where values which aren't instances of
57 basestring are pickled. Also, a new key '_pickled' contains a comma
58 separated list of keys corresponding to the pickled values.
59 '''
60 ret = {}
61 pickled_keys = []
62 for key, val in items.items():
63 if isinstance(val, basestring):
64 ret[key] = val
65 else:
66 pickled_keys.append(key)
67 ret[key] = pickle.dumps(val)
68 if pickled_keys:
69 ret['_pickled'] = ','.join(pickled_keys)
70 return ret
1816def LoadDictionary(filename):
1817 """
1818 Given a binary file (containing a dictionary), return dictionary
1819 containing parsed DICOM information.
1820 """
1821 import pickle
1822
1823 fp = open(filename, "rb")
1824 info = pickle.load(fp)
1825 fp.close()
1826 return info

Related snippets