Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
level3-lesson18-diy2
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c687b705
authored
Sep 22, 2024
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
6e2feafe
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
11 deletions
my_app.py
user.txt
my_app.py
View file @
c687b705
...
@@ -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
)
user
s
=
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
.
showwarn
n
ing
(
"sdfygbs"
,
"填完整,小土豆"
)
messagebox
.
showwarning
(
"sdfygbs"
,
"填完整,小土豆"
)
elif
name
in
users
:
elif
name
in
users
:
messagebox
.
showwarn
n
ing
(
"sdg"
,
"已存在,小土豆"
)
messagebox
.
showwarning
(
"sdg"
,
"已存在,小土豆"
)
elif
passw
w
ord1
!=
password2
:
elif
password1
!=
password2
:
messagebox
.
showwarn
n
ing
(
"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
):
...
...
user.txt
View file @
c687b705
{"admin": "123456"}
{"admin": "123456", "1": "1", "1123456765456\u80ce45656545": "123454321", "12": "12"}
\ No newline at end of file
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment