zoukankan      html  css  js  c++  java
  • python 登入接口

    '''
    编写登陆接口
    
    •输入用户名密码
    •认证成功后显示欢迎信息
    •输错三次后锁定
    •并且用户名被就在restrictuser.txt下面,如果想解除锁定就要到文本下面删除user
    '''
    
    countnumber=0
    while countnumber <3: ###输入三次错误后锁定
    #    for i in  open (r"D:Pythonuserpasswd.txt").readlines():
        username = input("Please input the username:")
        password = input("Please input the passwd:")
        f1 = open(r'D:Python
    estrictuser.txt').read()
        rest=f1.count(username)
        print(rest)
        if rest >= 3:
            print("Your ID have been locked,Please contact the administrator")
            exit()
        i = open(r"D:Pythonuserpasswd.txt").read()
    #    print(i.split(" ")[1].strip())
    #    print(type(i.split(" ")[0]))
    #    break
        if username == i.split(" ")[0].strip()  and password == i.split(" ")[1].strip():
            print ("Welcome Login")
            exit()
        else:
            print("You have %s chance"%(2-countnumber))
            countnumber+=1
            f = open(r'D:Python
    estrictuser.txt','a')
            f.writelines('
    ' + username )
            f.close()
            continue
    else:
        print("Your ID have been locked")
        exit()
    #a = f.readline()
    #print (f)
    #错误信息
    #SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 9-10: truncated uXXXX escape
    
    #print (username,password)
  • 相关阅读:
    Spock
    Spock
    Spock
    Spock
    Spock
    Spock
    Python3 与 Python2 的不同
    python 文件处理
    Django 数据迁移
    Python 特殊方法
  • 原文地址:https://www.cnblogs.com/lwsup/p/7084127.html
Copyright © 2011-2022 走看看