Fork me on GitHub

登录认证程序

 

作业需求

基础需求:
让用户输入用户名密码
认证成功后显示欢迎信息
输错三次后退出程序

升级需求:
可以支持多个用户登录 (提示,通过列表存多个账户信息)
用户3次认证失败后,退出程序,再次启动程序尝试登录时,还是锁定状态(提示:需把用户锁定的状态存到文件里)

代码

# -*- coding:utf-8 -*-
#Author:Kris

# count = 0
# _username = "kris"
# _passworld = "abc123"
# while count < 3:
#     username = input("username:")
#     passworld = input("passworld:")
#     if username == _username and passworld == _passworld:
#         print("Welcome to login in !")
#         break
#     else:
#         print("您的输入有误,请重新输入")
#     count += 1

#升级需求
count = 0
_names = ["kris","andy"]
_passworlds = ["abc123","123e"]
while count < 3:
    username = input("username:")
    passworld = input("passworld:")
    if username == "kris" and passworld == "abc123":
        print("Welcome kris loggin in...")
        break
    elif username == "andy" and passworld == "123e":
        print("Welcome andy loggin in...")
        break
    else:
        print("您的输入有误,请重新输入")
    count += 1

 

posted @ 2018-04-21 15:29  kris12  阅读(343)  评论(0编辑  收藏  举报
levels of contents