-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.py
More file actions
39 lines (28 loc) · 1.03 KB
/
data.py
File metadata and controls
39 lines (28 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import json
def writeData(account_Name, phone_Number, password):
def write_json(data, filename='data.json'):
with open(filename,'w') as f:
json.dump(data, f, indent=4)
with open('data.json') as json_file:
data = json.load(json_file)
temp = data['Persons']
# python object to be appended
y = {"account_Name":account_Name,
"phone_Number": phone_Number,
"password": password
}
# appending data to emp_details
temp.append(y)
write_json(data)
def printData():
with open('data.json') as json_file:
data = json.load(json_file)
for p in data['Persons']:
print('Account Name: ' + p['account_Name'])
print('Phone Number: ' + p['phone_Number'])
print('Password: ' + p['password'])
print('')
def getData():
with open('data.json') as json_file:
data = json.load(json_file)
return(data['Persons'])