-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjson_user_pass.py
33 lines (29 loc) · 919 Bytes
/
json_user_pass.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
import json
try:
with open("json_user_pass.json", "r") as file:
data = json.load(file)
print(data)
except:
data = {}
print('No eisting file. Start from scratch')
try:
while True:
task = input('Enter a to add or s to search')
if task == 'a':
name = input('Enter username ')
passw = input('Enter password ')
data[name] = passw
if task == 's':
name = input('Enter username ')
if name in data:
passw = input('Enter password')
if passw == data[name]:
print('Password correct')
else:
print('Password not correct')
else:
print('Username unknown')
except KeyboardInterrupt:
with open("json_user_pass.json", "w") as file:
json.dump(data, file)
print(data)