Created
October 8, 2018 14:50
-
-
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
This file contains 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
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