Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson4_1
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
ab079ec2
authored
Jun 23, 2024
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
9e5d4bbe
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
6 deletions
diy1.py
sab2.py/ss dqw
sab2.py/wsqqwsqw
diy1.py
View file @
ab079ec2
username
=
"搜索"
# 保存在服务器数据库中的用户账号(正确的账号)
username
=
"搜索"
# 保存在服务器数据库中的用户账号(正确的账号)
userpassword
=
"123456"
#
保存在服务器数据库中的用户密码(正确的
userpassword
=
"123456"
#
保存在服务器数据库中的用户密码(正确的
while
True
:
while
True
:
name
=
input
(
"请输入账号:"
)
name
=
input
(
"请输入账号:"
)
password
=
input
(
"请输入密码:"
)
password
=
input
(
"请输入密码:"
)
break
#
break
if
username
==
name
and
userpassword
==
password
:
if
username
==
name
and
userpassword
==
password
:
print
(
"登陆日本成功"
)
print
(
"登陆日本成功"
)
break
else
:
if
userpassword
!=
password
and
username
!=
name
:
input
(
"错误"
)
input
(
"帐号和密码错误"
)
# 请用input()实现用户输入账号、密码的功能
\ No newline at end of file
if
username
!=
name
:
input
(
"帐号错误"
)
if
userpassword
!=
password
:
input
(
"密码错误"
)
# 请用input()实现用户输入账号、密码的功能
#input输出参数内容 输入 返回值
#print 输出
sab2.py/ss dqw
0 → 100644
View file @
ab079ec2
sab2.py/wsqqwsqw
0 → 100644
View file @
ab079ec2
users = {
"zhangsan": "001",
"lisi": "002",
"wangwu": "003"
}
# 登录尝试次数
attempt_limit = 3
# 当前登录尝试次数
current_attempts = 0
def login():
global current_attempts
while current_attempts < attempt_limit:
username = input("请输入用户名:")
password = input("请输入密码:")
# 检查用户名是否存在
if username not in users:
print("用户名不存在,请重新输入!")
current_attempts += 1
continue
# 检查密码是否正确
if users[username] != password:
print("密码错误,请重新输入!")
current_attempts += 1
continue
# 用户名和密码都正确
print(f"欢迎 {username} 登录!")
return
# 如果三次尝试机会都用完,则给出提示并结束程序
print("您已连续三次输入错误,程序将退出。")
# 运行登录函数
login()
\ 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