python_01作业(编写登陆接口)

python_01作业(编写登陆接口)_第1张图片

import linecache
error=0
for j in range(0,3,1):
    name = input("账户:")
    error_name= linecache.getline("D:\\work1error.txt", 1)
    if int(name)==int(error_name):
        print("用户被锁定")
        error=1
        break
    else: #先开始这一部分的用户名判断
         for i in range(1,5,1):
             the_name = linecache.getline("D:\\work1name.txt", i)
             if int(the_name)==int(name):
                 print("right")
                 break
         if int(the_name) == int(name):
             break
         else:
             print('账户不存在')

# 对应密码判断
if  error!=1 and int(the_name) == int(name):
     the_pass = linecache.getline("D:\\work1pass.txt", i)
     for k in range(0,3,1):
        password = input("输入密码:")
        if int(the_pass) == int(password):
            print("登陆成功")
            break
        else:
            print("密码错误")

#三次错误密码输入后的处理            
if  error!=1 and int(the_name) == int(name) and int(the_pass) != int(password):
    f=open("D:\work1error.txt",'w')
    f.write(name)
    f.close()

你可能感兴趣的:(python)