Created
November 1, 2019 16:00
-
-
Save Dulani/24782c9649a37e73f1be7a5262687e40 to your computer and use it in GitHub Desktop.
Simple example: Python pickle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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