本文共 830 字,大约阅读时间需要 2 分钟。
编写一个登陆接口,要求如下
import oscount = 0#读取用户列表user_check = open('userlist.txt','r')userlist = user_check.read()user_check.close()#读取锁定用户列表user_lock = open('userlock.txt','r')lock = user_lock.read()user_lock.close()username = input("输入用户名:")while count < 3: passwd = input("请输入密码:") if username in lock: print("账号已锁定,请联系管理员") break else: if username in userlist: if passwd == '123456': print("welcome "+username) break else: print("密码错误") count += 1 else: print("您输入的账号不存在") breakelse: print("连续三次输错密码,账号被错定") #开始将连续三次输错密码的账号写入锁定用户列表 add_lock = open('userlock.txt','a') add_lock.write(username) add_lock.close()
转载于:https://blog.51cto.com/ycentos/2113142