要求:
1.输入用户名密码
2.认证成功显示欢迎信息
3.输错三次后锁定用户名
4.要求将用户名密码保存至本地
_user = "alex"
_password = "abc123"
passed_authentication= False
for i in range(3):
username = input("username:")
password = input("password:")
if username == _user and password == _password:
print("Welcome %s login!",username)
passed_authentication = True
break
else:
print("invalid username or password!")
if not passed_authentication:
print("超过登录次数")
passed_authentication为flag 标志位
可以不用passed_authentication