File size: 501 Bytes
8f0e835 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import json
def create_json(one_individual={}):
# Serializing json
one_individual = json.dumps(one_individual, indent=4)
# Writing to sample.json
with open("data/one_individual.json", "w") as outfile:
outfile.write(one_individual)
def add_data_to_individual(key, value):
with open("data/one_individual.json", 'r') as openfile:
# Reading from json file
one_individual = json.load(openfile)
one_individual[key] = value
create_json(one_individual)
|