Skip to content

Instantly share code, notes, and snippets.

@LiamHz
Created October 8, 2018 14:50
Show Gist options
  • Save LiamHz/35eeb4a6d9b53f6d5d841da6293bc7d8 to your computer and use it in GitHub Desktop.
Save LiamHz/35eeb4a6d9b53f6d5d841da6293bc7d8 to your computer and use it in GitHub Desktop.
A demo of how to use JSON to read and write to disk
import json
# Read variables from disk
with open('data.json', 'r') as json_file:
data = json.load(json_file)
a = data['a']
b = data['b']
c = data['c']
d = data['d']
# Write variables to disk
with open('lists.json', 'w') as outfile:
data = {}
data['a'] = a
data['b'] = b
data['c'] = c
data['d'] = d
json.dump(data, outfile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment