Pruefungskatalog/json_writer.py

14 lines
322 B
Python

import json
# Fills my Json File with object from 0 to 299
counter = 0
data = [{counter: {'question': '', 'answer': ''}}]
while counter < 300:
data.append({counter: {'question': '', 'answer': ''}})
counter += 1
json_string = json.dumps(data)
with open('jsontest.json', 'w') as file:
file.write(json_string)