zoukankan      html  css  js  c++  java
  • 练习一

    users_info={'xiaoming':['123','age=23','wo shi a yangguangboy'],'xiaoxu':['456','age=24','wo shi a yangguanggirl']}

    fail_count = 0
    flag = True
    fail_list = []
    count = 1
    while flag:

      user = input("请输入用户名:")
      password = input("请输入密码:")

      if user == '' or password == '':

        print("输入用户名或密码不能为空,请重新输入")
        continue

    #验证输入的用户名时否在黑名单里
      with open('heimingdan.txt', 'r') as file:
        while True:
          line = file.readline().strip()
          # print(line)

          if user == line:
            count = count-1
            break

          if line == '':
            break
        # print(count)
        if count == 0:
          print("该用户登陆失败已超出次数,请明天再登陆")
          break


      if user in users_info.keys() and users_info[user][0] == password:
        print("登陆成功")
        # print(fail_count)
        fail_count = 0
        break
      else:
        if user in users_info.keys():
          fail_count=fail_count+1

          # print(fail_count)
        if fail_count == 3:
          # fail_list.append(user)
          # print(fail_list)
          with open('heimingdan.txt','a') as file:
            file.write(user.strip()+'\n')
          print("错误超出了3次,今天不能再登陆了")
          break
        print("账户密码错误,请重新输入:")
        continue

  • 相关阅读:
    Scala伴生对象
    Python之随机森林实战
    DevOps 发展融合运维可视化
    为什么选用 React 创建混合型移动应用?
    查找并修复Android中的内存泄露—OutOfMemoryError
    精华阅读第 12 期 | 最新 App Store 审核指南与10大被拒理由?
    Python 应用剖析工具介绍
    的确,Java存在缺陷。但是……
    APM终端用户体验监控分析(下)
    ASP.NET MVC 应用提速的十种方法
  • 原文地址:https://www.cnblogs.com/linux985/p/10208527.html
Copyright © 2011-2022 走看看