Created
August 1, 2021 05:25
-
-
Save av1d/5e0d38d94b174646affc79e0183d6477 to your computer and use it in GitHub Desktop.
Simple way to save and load lists using JSON module. Use for saving configuration settings, etc. which don't need to be edited by the user.
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 | |
one = "Hello" | |
two = 7136942066631337 | |
three = "//#$%^&*((*&^\\" | |
d = [str(one), str(two), str(three)] | |
with open("config.json", 'w') as f: | |
json.dump(d, f) | |
print("Wrote: " + str(d) + " to file.") | |
with open("config.json", 'r') as f: | |
savedconfigs = json.load(f) | |
print("Read: " + str(savedconfigs) + " from file.") | |
print("Elements itemized:") | |
for i in range(0,len(savedconfigs),1): | |
print savedconfigs[i] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment