Skip to content

Instantly share code, notes, and snippets.

@vunb
Created October 27, 2017 06:16
Show Gist options
  • Save vunb/e1a5e09f976bd2d781aec8b538ad3d88 to your computer and use it in GitHub Desktop.
Save vunb/e1a5e09f976bd2d781aec8b538ad3d88 to your computer and use it in GitHub Desktop.
Convert python pickle format to json
import sys
try:
import simplejson as json
except ImportError:
import json
try:
import cPickle as pickle
except ImportError:
import pickle
with open("dictionary.pickle", "rb") as f:
with open('dictionary.json', 'w') as outfile:
json.dump(pickle.load(f), outfile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment