File size: 547 Bytes
7083742 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import os
import json
def create_folder(path):
if not os.path.exists(path):
os.makedirs(path)
def save_json(file_path, data):
if os.path.exists(file_path):
json_data = load_json(file_path)
json_data['appointments'].append(data)
else:
json_data = {'appointments': [data]}
with open(file_path, 'w', encoding='utf-8') as outfile:
json.dump(json_data, outfile, indent=4)
def load_json(file_path):
with open(file_path, 'r', encoding='utf-8') as infile:
return json.load(infile) |