snippets

🔌 Toolbox of short, reusable pieces of code and knowledge.

View the Project on GitHub rosikand/snippets

Pickling in Python

Pickling (serializing)

import pickle
out_file = open("path/file-name.pkl", "wb")
pickle.dump(object_to_pickle, out_file)
out_file.close()

Un-pickling (unserializing)

import pickle
in_file = open('path/file-name.pkl', 'rb')
loaded_object = pickle.load(in_file)