Created
October 30, 2019 13:35
-
-
Save etigui/abcae14c0b33f8ce523c6e3e1dfbaec2 to your computer and use it in GitHub Desktop.
Python: add list to dict and save as json
This file contains hidden or 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
name = dict() | |
name["data"] = list() | |
with open('file.json', 'a') as myfile: | |
for d in ["1", "2"]: | |
name["data"].append({"a": d[0], "b": d[1]}) | |
json.dump(name, myfile, indent=2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment