Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson4_3
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
862b1096
authored
Nov 19, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
c08f1189
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
11 deletions
P1114.py
P1114.py
View file @
862b1096
...
@@ -2,18 +2,35 @@
...
@@ -2,18 +2,35 @@
usename
=
"python"
usename
=
"python"
password
=
"123456"
password
=
"123456"
#设置计数变量i,限制登录次数
i
=
3
#用户名和密码的输入与判断
#用户名和密码的输入与判断
while
True
:
while
True
:
#1、用input提示用户输入用户名和密码,分别保存在us变量和ps变量中
#4、当i不为零时,才能继续输入用户名和密码
us
=
input
(
"请输入您的用户名:"
)
if
i
>
0
:
ps
=
input
(
"请输入您的密码:"
)
i
-=
1
#1、用input提示用户输入用户名和密码,分别保存在us变量和ps变量中
us
=
input
(
"请输入您的用户名:"
)
#3-1、如果用户名输入不正确,提示重新输入
if
us
!=
usename
:
print
(
"用户名不正确,请重新输入!"
)
print
(
"您还有"
+
str
(
i
)
+
"次机会"
)
continue
ps
=
input
(
"请输入您的密码:"
)
#3-2、如果密码输入不正确,提示重新输入
if
ps
!=
password
:
print
(
"密码不正确,请重新输入!"
)
print
(
"您还有"
+
str
(
i
)
+
"次机会"
)
continue
#2、如果用户名和密码正确,输出登陆成功
#2、如果用户名和密码正确,输出登陆成功
if
(
us
==
usename
)
and
(
ps
==
password
)
:
if
(
us
==
usename
)
and
(
ps
==
password
)
:
print
(
"用户名、密码正确,登陆成功!"
)
print
(
"用户名、密码正确,登陆成功!"
)
break
else
:
print
(
"您的账户已被锁定,请携带身份证来我司解锁账号!"
)
exit
()
print
(
"欢迎光临XXX网站!"
)
#3、如果用户名、密码输入不正确,提示重新输入
if
us
!=
usename
:
\ No newline at end of file
print
(
"用户名不正确,请重新输入!"
)
if
ps
!=
password
:
print
(
"密码不正确,请重新输入!"
)
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