Seraph19 commited on
Commit
5bcf2a3
1 Parent(s): d367805

Create data.py

Browse files
Files changed (1) hide show
  1. data.py +12 -0
data.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+
3
+ def load_data(filename="data.json"):
4
+ try:
5
+ with open(filename, "r") as f:
6
+ data = json.load(f)
7
+ except FileNotFoundError:
8
+ data = {} # Initialize an empty dictionary if no data file exists
9
+ return data
10
+ def save_data(data, filename="data.json"):
11
+ with open(filename, "w") as f:
12
+ json.dump(data, f)