我的测试环境,win7,python3.6,Pycharm社区版
提示输入用户名,和密码
判断是否被锁定
判断用户名和密码是否匹配
输入错误三次,账号被锁定
real_user = 'channel' #正确的用户名
real_passwd = 'asdf' #正确的密码
lock_user = ['tiaozhan'] #锁定账号列表
while True:
user_input = input("输入用户名")
passwd_input = input('your passwd:')
if user_input in lock_user:
print('用户 %s 被锁定' %user_input)
elif user_input == real_user:
i = 0
while i <3:
# for i in range(3):
# passwd_input = input("your password:")
if passwd_input == real_passwd:
print('yes, you got it')
break
exit()
else:
print("passwd is False")
if i==2:
print("the user has been locked")
lock_user.append(user_input)
exit()
else:
passwd_input = input("your passwd again:")
i +=1
else:
print("用户不存在")
怎么才能实现类似“淘宝”那样的登录提示呢?