Commit c687b705 by BellCodeEditor

auto save

parent 6e2feafe
Showing with 17 additions and 11 deletions
...@@ -4,7 +4,7 @@ import json ...@@ -4,7 +4,7 @@ import json
with open("user.txt","r",encoding="utf_8") as f: with open("user.txt","r",encoding="utf_8") as f:
info =f.read() info =f.read()
user =json.loads(info) users =json.loads(info)
def login_to_reg(): # 登录界面转注册界面 def login_to_reg(): # 登录界面转注册界面
app_login.root.destroy() app_login.root.destroy()
...@@ -18,22 +18,28 @@ def reg_to_login(): # 注册界面转登录界面 ...@@ -18,22 +18,28 @@ def reg_to_login(): # 注册界面转登录界面
app_login=My_login() app_login=My_login()
app_login.show() app_login.show()
def register(): # 注册验证 def register(): # 注册验证
name,password1,password2 = app_reg.get_input() name,password1,password2 = app_reg.get_input()
if name=="" or password1==""or password2=="": if name=="" or password1==""or password2=="":
messagebox.showwarnning("sdfygbs","填完整,小土豆") messagebox.showwarning("sdfygbs","填完整,小土豆")
elif name in users: elif name in users:
messagebox.showwarnning("sdg","已存在,小土豆") messagebox.showwarning("sdg","已存在,小土豆")
elif passwword1 != password2: elif password1 != password2:
messagebox.showwarnning("www","不一致,小土豆") messagebox.showwarning("www","不一致,小土豆")
else: else:
users[name]=password1 users[name]=password1
content =json.dumps(users)
with open("user.txt","w",encoding="utf_8") as file:
file.write(content)
messagebox.showinfo("成功","小土豆")
def login(): # 登录验证 def login(): # 登录验证
pass name,password = app_login.get_input()
pwd =users.get(name)
if pwd==password:
messagebox.showinfo("成功","小土豆")
else:
messagebox.showwarning("错误","小土豆")
class My_login(): # 登录窗口 class My_login(): # 登录窗口
def __init__(self): def __init__(self):
......
{"admin": "123456"} {"admin": "123456", "1": "1", "1123456765456\u80ce45656545": "123454321", "12": "12"}
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment