Skip to content

Instantly share code, notes, and snippets.

@zhanglongqi
Created January 25, 2017 07:14
Show Gist options
  • Save zhanglongqi/542042313880ed4b166befd74d3ff86e to your computer and use it in GitHub Desktop.
Save zhanglongqi/542042313880ed4b166befd74d3ff86e to your computer and use it in GitHub Desktop.
Pickle example of python
import pickle
data1 = {'foo': [1, 2, 3],
'bar': ('Hello', 'world!'),
'baz': True}
# write the pickled data to the file jar
with open('data.pkl', mode='wb') as jar:
pickle.dump(data1, jar, fix_imports=True)
# load it into a variable
with open('data.pkl', mode='rb') as pkl_file:
data2 = pickle.load(pkl_file)
print(data2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment