Commit b19d2fcf by BellCodeEditor

save project

parent b159d416
Showing with 8 additions and 7 deletions
...@@ -3,7 +3,8 @@ from tkinter import messagebox ...@@ -3,7 +3,8 @@ from tkinter import messagebox
import json 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()
users=json.loads(info) user=json.loads(info)
# global user
def login_to_reg(): # 登录界面转注册界面 def login_to_reg(): # 登录界面转注册界面
app_login.root.destroy() app_login.root.destroy()
...@@ -18,16 +19,16 @@ def register(): # 注册验证 ...@@ -18,16 +19,16 @@ def register(): # 注册验证
name,password1,password2=app_reg.get_input() name,password1,password2=app_reg.get_input()
if name=='' and password1=='' and password2=='': if name=='' and password1=='' and password2=='':
messagebox.showwarning("警告","请填写完整") messagebox.showwarning("警告","请填写完整")
elif name in users: elif name in user:
messagebox.showwarning("警告","用户以存在") messagebox.showwarning("警告","用户以存在")
elif password1!=password2: elif password1!=password2:
messagebox.showwarning("警告","两次密码不一样") messagebox.showwarning("警告","两次密码不一样")
else: else:
users[name]=password1 user[name]=password1
messagebox.showwarning("警告","账号注册成功") messagebox.showwarning("警告","账号注册成功")
with open ("user.txt","w",encoding="utf-8") as f: with open ("user.txt","w",encoding="utf-8") as f:
f.write(json.dumps(users)) f.write(json.dumps(user))
users=json.loads(info) reg_to_login()
def login(): # 登录验证 def login(): # 登录验证
pass pass
......
{"admin": "123456"} {"admin": "123456", "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