Skip to content

Instantly share code, notes, and snippets.

@osin-vladimir
Created November 13, 2017 14:07
Show Gist options
  • Save osin-vladimir/eb3d3e85d605924e3e5f0e47ca12758b to your computer and use it in GitHub Desktop.
Save osin-vladimir/eb3d3e85d605924e3e5f0e47ca12758b to your computer and use it in GitHub Desktop.
save/load objects in python
# save/load objects in python
import pickle
def save_obj(obj, name ):
with open('obj/'+ name + '.pkl', 'wb') as f:
pickle.dump(obj, f, pickle.HIGHEST_PROTOCOL)
def load_obj(name ):
with open('obj/' + name + '.pkl', 'rb') as f:
return pickle.load(f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment