#!/usr/bin/env python3 #title :11-3.py #description :11.3: JSON-files schrijven #author :Marcel Haazen #email :marcel@haazen.xyz #date :07-11-2019 - 14:05 #edit_date :07-11-2019 - 14:05 #version :0.1 #usage :python3 11-3.py #notes : #python_version :3.7.4 #============================================================================== import json import datetime bestand = "inlogger.json" time = datetime.datetime.today().strftime("%a %d %b %Y, %H:%M:%S,") while True: naam = input("Wat is je achternaam? ") if naam == "einde": break voorl = input("Wat zijn je voorletters? ") gbdatum = input("Wat is je geboortedatum? ") email = input("Wat is je e-mail adres? ") gdict = {"inlogtijd": time, "naam": naam, "voorletters":voorl,"geb_datum": gbdatum, "e-mail": email} with open(bestand) as json_bestand: data = json.load(json_bestand) with open(bestand, "w") as json_bestand: data.append(gdict) json.dump(data, json_bestand, indent = 4)