zoukankan      html  css  js  c++  java
  • 模拟登录

    #coding:utf-8
    """
    1. 用户输入帐号密码进行登陆
    2. 用户信息保存在文件内
    3. 用户密码输入错误三次后锁定用户
    """



    dic={
    'egon1':{'password':'123','count':0},
    'egon2':{'password':'123','count':0},
    'egon3':{'password':'123','count':0},
    }
    flag=True
    while flag:
    name=input('type your name:').strip()
    with open('a.txt','r',encoding='utf-8') as red_user:
    if name in red_user.read().split('|'):
    print("账户已锁定")
    continue
    if name not in dic:
    print('name is not in dic')
    continue
    else:
    while flag:
    passwd=input('type your passwd:')
    if passwd!=dic[name]['password'] and dic[name]['count']<=2:
    print('passwd is wrong')
    dic[name]['count']+=1
    continue
    elif dic[name]['count']>2:
    print("chao guo 3 ci")
    user=open('a.txt','a',encoding='utf-8')
    user.write(name+'|')
    user.close()
    break
    if passwd==dic[name]['password']:
    print("login success")
    flag=False






  • 相关阅读:
    怎么在虚拟机下的Linux系统安装数据库
    bbs仿博客
    算法思想
    vue前后台交互
    vue项目内文件的使用和配置
    pycharm使用vue
    vue之vue-cookies
    跨域请求
    vue的常用插件
    vue的生命周期
  • 原文地址:https://www.cnblogs.com/lalashou/p/7867415.html
Copyright © 2011-2022 走看看