python 用户登录

Posted on 2019-04-23 15:09  S-skill  阅读(220)  评论(0编辑  收藏  举报

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里面的内容.
 

Copyright © 2024 S-skill
Powered by .NET 8.0 on Kubernetes