1.用户登录
count = 1 while count <= 3: username = input("请输入你的用户名;") password = input("请输入你的密码:") if username == "张三" and password == "123": print("登录成功") break else: print("登录失败") count = count + 1 else: print("你是不是有点傻!")
解释:首先要说一下, 这个" == " 表示判断, if username == "张三" and password =="123":
表示:如果用户名是 " 张三", 密码是 "123", 则登陆成功 , "break"是结束循环,停止当前本次循环
最后面的else 是如果你输入三次用户名或密码没有成功,则会打印print里面的内容.