-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy path21-method_for_recording.py
55 lines (35 loc) · 1.55 KB
/
21-method_for_recording.py
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# nistdb = {0:{'email': '[email protected]', 'u_name': 'winpass', 'password': 'winpass', 'phone': 99, 'age': 100},
#
# 1:{'email': '[email protected]', 'u_name': 'winpass', 'password': 'winpass', 'phone': 99, 'age': 100},
# 2:{'email': '[email protected]', 'u_name': 'winpass', 'password': 'winpass', 'phone': 99, 'age': 100},
# 3:{'email': '[email protected]', 'u_name': 'winpass', 'password': 'winpass', 'phone': 99, 'age': 100}
#
# }
nistdb={}
#print(nistdb)
#print(nistdb.keys())
def recording_all_data():
with open("nistdb.txt", 'w') as dbfile:
for i in range(len(nistdb)):
email = nistdb[i]["email"]
user_name = nistdb[i]["u_name"]
password = nistdb[i]["password"]
phone = nistdb[i]["phone"]
age = nistdb[i]["age"]
total_user_data = email + ' ' + user_name + ' ' + password + ' ' + str(phone) + ' ' + str(age) + '\n'
dbfile.write(total_user_data)
# print("data:", email, user_name, password, phone, age)
#print("Recorded")
def loading_data_from_file():
with open("nistdb.txt",'r') as dbfile:
datas=dbfile.readlines()
for one in datas:
oneData = one.split(" ")
id = len(nistdb)
data_form = {id:{"email":oneData[0],"u_name":oneData[1],"password":oneData[2],
"phone":oneData[3],"age":oneData[4]
}}
nistdb.update(data_form)
print(nistdb)
if __name__ =='__main__':
loading_data_from_file()