#Author:zhanghonglin
counter =
0
#确定真实用户名和密码
real_name =
"itssky"
real_password =
"itssoft"
#读取黑名单
f =
open
(
"black_user"
,
"r"
)
lock_file = f.read()
f.close()
user_name =
input
(
"请输入您的用户名:"
)
#判定是否是黑名单用户
for
i
in
range
(
1
):
if
user_name == lock_file:
print
(
"对不起,你的账户被锁定,无法登陆!"
)
exit
()
else
:
continue
#判定登陆次数
for
i
in
range
(
3
):
password =
input
(
"请输入您的密码:"
)
if
password == real_password:
print
(
"登陆成功!"
)
break
else
:
print
(
"登陆失败!"
)
counter +=
1
if
counter ==
3
:
print
(
"对不起!您的错误输入已达三次,即将锁定账户。"
)
f =
open
(
"black_user"
,
"w"
)
f.write(
"%s"
%user_name)
f.close()
转载于:https://blog.51cto.com/12239811/1876737