zoukankan      html  css  js  c++  java
  • day_1_登录接口

    #/usr/bin/env python3
    # -*- coding: utf-8 -*-
    ##This is an account login authentication
    ##Version 1.0
    ## # Created At 2016-4-11
    ##Author He Wei
    '''
    Logindauth.txt ##验证帐号
    aaaaa 123456
    user passwd
    Loginfailed.txt ##登录失败录入
    bbbbb
    ccccc
    user
    Blacklist.txt ##黑名单
    hhhhhhh
    dddddd
    user
    '''
    import sys
    Logindauth_file = "Logindauth.txt"
    Loginfailed_file = "Loginfailed.txt"
    Blacklist_file = "Blacklist.txt"


    #Name = input("请输入用户名:")
    #Passwd = (input("请输入密码:"))
    ##检查黑名单

    ##认证帐号
    user_county = True
    while user_county == True :
    Name = input("请输入用户名:")
    Passwd = (input("请输入密码:"))
    if len(Name) == 0:
    print("帐号不能为空")
    continue
    with open(Blacklist_file,"r") as f:
    lines = []
    for line in f.readlines():
    lines.append(line.strip())
    if lines.count(Name) != 0:
    print("该帐号已被锁定, 请联系管理员解除")
    sys.exit()
    with open(Logindauth_file,"r") as d:
    for line in d.readlines():
    user,pawd = line.strip().split() ##以空格为分割符将一行类容分成2份,分别为帐号和密码
    if Name == user and Passwd == pawd:
    print("欢迎登录XX系统")
    #user_county == False
    #break
    sys.exit()
    #else:
    print(user,pawd)
    print("帐号或密码错误,请重新输入 输错三次将被锁定")
    with open(Loginfailed_file,"a") as t : ##将登录失败帐号写入文本中
    t.write(Name)
    t.write(" ")
    with open(Loginfailed_file,"r") as tt: ##检测文本账户是否超过三次
    number_cs = [None]
    for number in tt.readlines():
    number_cs.append(number.strip())
    if number_cs.count(Name) >= 3:
    with open(Blacklist_file,"a") as f:
    f.write(Name)
    f.write(" ")
    sys.exit()
    else:
    break ##不满足3次,结束for循环,重新进行新一轮用户验证
    #if user_county == False:
    #print("进入登录界面")
    才开始接触py,其他功能在以后慢慢完善,有错误的地方,请各位及时提出,谢谢~
  • 相关阅读:
    嵌入式工程师C语言面试常见的0x10个问题
    C语言初学者网站推荐
    strlen和sizeof
    基于Docker搭建GitLab和Maven私服
    linux暴露端口可以被外部访问
    MySQL新增用户及赋予权限
    Docker添加域名解析
    Netstat 网络命令详解
    Mysql索引太长导致同步数据结构失败解决方法
    完美解决Cannot download "https://github.com/sass/node-sass/releases/download/binding.nod的问题
  • 原文地址:https://www.cnblogs.com/heweiblog/p/5395424.html
Copyright © 2011-2022 走看看