zoukankan      html  css  js  c++  java
  • Python-day1 登陆作业

    # 1、写一个登录的程序,
    # 1、最多登陆失败3次
    # 2、登录成功,提示欢迎xx登录,今天的日期是xxx,程序结束
    # 3、要检验输入是否为空, 账号和密码不能为空
    # 4、账号不区分大小写
    import time
    users = {}
    time = time.strftime('%Y-%m-%d %H:%M:%S')
    with open('user.txt')as fr:
        for line in fr:
            line = line.strip('
    ') #读出来会有换行符,需要去掉
            if line.strip():
                user,pwd = line.split(',')
                users[user] = pwd
    while True:
        username = input('请输入账号:').lower().strip()
        password = input('请输入密码:').strip()
        if username == '' and password == '':
            print('不能为空')
        elif username in users:
            if password != users.get(username):
                print('%s登录成功,今天的日期是%s' % (username,time))
                break
            else:
                print('密码不对')
        else:
            print('账户不存在')
  • 相关阅读:
    Harbor安装 -- 企业级Registry仓库
    https原理
    第十节
    第九节
    第八节
    Spring中用到的部分设计模式
    代理模式及实现
    单例模式的实现
    索引
    第九章 集合
  • 原文地址:https://www.cnblogs.com/brf-test/p/12227179.html
Copyright © 2011-2022 走看看