You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.1 KiB

5 years ago
  1. #!/usr/bin/env python3
  2. #title :11-3.py
  3. #description :11.3: JSON-files schrijven
  4. #author :Marcel Haazen
  5. #email :marcel@haazen.xyz
  6. #date :07-11-2019 - 14:05
  7. #edit_date :07-11-2019 - 14:05
  8. #version :0.1
  9. #usage :python3 11-3.py
  10. #notes :
  11. #python_version :3.7.4
  12. #==============================================================================
  13. import json
  14. import datetime
  15. bestand = "inlogger.json"
  16. time = datetime.datetime.today().strftime("%a %d %b %Y, %H:%M:%S,")
  17. while True:
  18. naam = input("Wat is je achternaam? ")
  19. if naam == "einde":
  20. break
  21. voorl = input("Wat zijn je voorletters? ")
  22. gbdatum = input("Wat is je geboortedatum? ")
  23. email = input("Wat is je e-mail adres? ")
  24. gdict = {"inlogtijd": time, "naam": naam, "voorletters":voorl,"geb_datum": gbdatum, "e-mail": email}
  25. with open(bestand) as json_bestand:
  26. data = json.load(json_bestand)
  27. with open(bestand, "w") as json_bestand:
  28. data.append(gdict)
  29. json.dump(data, json_bestand, indent = 4)