-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.py
More file actions
53 lines (42 loc) · 1.54 KB
/
user.py
File metadata and controls
53 lines (42 loc) · 1.54 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import json
from os import path
userFile = "user.json"
class user:
def __init__(self):
self.username = None
self.password = None
self.thisdict = {}
def registration(self):
print("please register username and password")
self.getUsername()
self.thisdict[self.username] = self.password
print("dictionary luuu",self.thisdict)
def getUsername(self):
print("***********************************************")
self.username = input("User name: ")
self.password = input("password: ")
def getDict(self):
if path.isfile(userFile):
with open(userFile) as json_file:
self.thisdict = json.load(json_file)
print("Current account", self.thisdict)
def logIn(self):
tmp = 0
while (1):
wrongP = True
if tmp != 0 & wrongP == True:
print("wrong passwork and please type again")
print("please input username and password")
self.getUsername()
if self.thisdict[self.username] == self.password:
wrongP = False
print("you are logging")
print("***********************************************")
break
else:
wrongP = True
tmp = tmp + 1
def saveFile(self):
print("curent dictionary", self.thisdict)
with open(userFile, 'w') as file:
json.dump(self.thisdict, file)