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,其他功能在以后慢慢完善,有错误的地方,请各位及时提出,谢谢~
  • 相关阅读:
    [shell]Shell经常使用特殊符号
    谈谈大三找暑假实习
    使用zTree控件制作的表格形式的树形+数据菜单
    Bestcoder #47 B Senior's Gun
    使用awrextr.sql导出awr原始数据
    linux/shell 文本文件删除/删掉空行
    python 统计文本文件的行数
    check if a linux process is done using bash 检查进程是否在运行
    umount移动硬盘遇到device is busy问题
    Python读写文件
  • 原文地址:https://www.cnblogs.com/heweiblog/p/5395424.html
Copyright © 2011-2022 走看看