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

  • 相关阅读:
    复杂网络研究的委员老师信息总合
    numpy读取本地数据和索引
    numpy数组的计算
    numpy数组的创建
    python画图的工具及网站
    matplotlib直方图
    matplotlib.legend()函数用法
    matplotlib条形图
    matplotlib散点图
    matplotlib折线图
  • 原文地址:https://www.cnblogs.com/linux985/p/10208527.html
Copyright © 2011-2022 走看看