Skip to content

Instantly share code, notes, and snippets.

@Dulani
Created November 1, 2019 16:00
Show Gist options
  • Save Dulani/24782c9649a37e73f1be7a5262687e40 to your computer and use it in GitHub Desktop.
Save Dulani/24782c9649a37e73f1be7a5262687e40 to your computer and use it in GitHub Desktop.
Simple example: Python pickle
# Save a dictionary into a pickle file.
# https://wiki.python.org/moin/UsingPickle
import pickle
favorite_color = { "lion": "yellow", "kitty": "red" }
pickle.dump( favorite_color, open( "test.pickle", "wb" ))
# Load the dictionary back from the pickle file.
more_favorite_colors = pickle.load(open( "test.pickle", "rb" ))
# favorite_color is now { "lion": "yellow", "kitty": "red" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment