Ich bin nur Nutzer kein Programmier, ich habe vom bekannten ein script bekommen. Auszug siehe unten. leider sind die Zeilen 2 bis x falsch formatiert oder gespeichert, könnte die vielleicht jemand für mich richtig anordnen ? das wäre sehr nett, habe da wirklich 0 ahnung.
Danke im voraus für die Hilfe
Mfg
Code: Alles auswählen
def load_saved_configs():
"""Load saved configurations from file.""" if not os.path.exists(CONFIG_FILE):
return {} with open(CONFIG_FILE, "r") as f:
return json.load(f)
def save_config(events):
"""Save a new configuration with an incremental ID."""
configs = load_saved_configs()
# Determine new config ID
new_id = str(max(map(int, configs.keys()), default=0) + 1)
configs[new_id] = events
with open(CONFIG_FILE, "w") as f:
json.dump(configs, f, indent=4)
print(f"Configuration saved as ID {new_id}.")