Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
level3-lesson18-diy3
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
ead409fa
authored
Aug 10, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
05eabe83
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
14 deletions
my_app.py
user.txt
my_app.py
View file @
ead409fa
import
tkinter
import
tkinter
from
tkinter
import
messagebox
from
tkinter
import
messagebox
import
json
import
json
import
random
def
login_to_reg
():
# 登录界面转注册界面
def
login_to_reg
():
# 登录界面转注册界面
app_login
.
root
.
destroy
()
app_login
.
root
.
destroy
()
...
@@ -20,7 +20,6 @@ def register(): # 注册验证
...
@@ -20,7 +20,6 @@ def register(): # 注册验证
with
open
(
"user.txt"
,
"r"
,
encoding
=
"utf-8"
)
as
f
:
with
open
(
"user.txt"
,
"r"
,
encoding
=
"utf-8"
)
as
f
:
a
=
f
.
read
()
a
=
f
.
read
()
users
=
json
.
loads
(
a
)
users
=
json
.
loads
(
a
)
b
=
random
.
randint
(
1
,
100
)
name
,
password1
,
password2
=
app_register
.
get_input
()
name
,
password1
,
password2
=
app_register
.
get_input
()
if
name
==
""
or
password1
==
""
or
password2
==
""
:
if
name
==
""
or
password1
==
""
or
password2
==
""
:
messagebox
.
showwarning
(
"警告"
,
"请填写完整的注册信息"
)
messagebox
.
showwarning
(
"警告"
,
"请填写完整的注册信息"
)
...
@@ -28,23 +27,14 @@ def register(): # 注册验证
...
@@ -28,23 +27,14 @@ def register(): # 注册验证
messagebox
.
showwarning
(
"警告"
,
"该用户名已被注册"
)
messagebox
.
showwarning
(
"警告"
,
"该用户名已被注册"
)
elif
password1
!=
password2
:
elif
password1
!=
password2
:
messagebox
.
showwarning
(
"警告"
,
"请重新输入密码"
)
messagebox
.
showwarning
(
"警告"
,
"请重新输入密码"
)
elif
b
==
50
:
messagebox
.
showerror
(
"错误"
,
"输入没问题,但你还是不能注册(doge)"
)
else
:
else
:
users
[
name
]
=
password1
users
[
name
]
=
password1
messagebox
.
showinfo
(
"提示"
,
"注册成功"
)
with
open
(
"user.txt"
,
"w"
,
encoding
=
"utf-8"
)
as
f
:
with
open
(
"user.txt"
,
"w"
,
encoding
=
"utf-8"
)
as
f
:
a
=
json
.
dumps
(
users
)
a
=
json
.
dumps
(
users
)
f
.
write
(
a
)
f
.
write
(
a
)
reg_to_login
()
def
login
():
# 登录验证
def
login
():
# 登录验证
name
,
password
=
app_login
.
get_input
()
pass
a
=
users
.
get
(
name
)
if
password
!=
a
or
password
==
None
:
messagebox
.
showwarning
(
"警告"
,
"用户名或密码错误"
)
else
:
messagebox
.
showerror
(
"温馨提醒"
,
"前面的路,等更新以后再来吧"
)
class
My_login
():
# 登录窗口
class
My_login
():
# 登录窗口
def
__init__
(
self
):
def
__init__
(
self
):
...
...
user.txt
View file @
ead409fa
{"admin": "123456", "abc": "1145114", "aaa": "111"}
{"admin": "123456","abc": "1145114"}
\ 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