Skip to content

Instantly share code, notes, and snippets.

@av1d
Created August 1, 2021 05:25
Show Gist options
  • Save av1d/5e0d38d94b174646affc79e0183d6477 to your computer and use it in GitHub Desktop.
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.
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