python登陆接口

mac2022-06-30  71

user = "jack"password = 123count = 0def write_lock_list(name): #将输入的用户名写入文件当中 file = open('lock_list','w') file.writelines(name) file.close()def read_lock_list(name): #读取列表中用户 file =open('lock_list','r') file_user=file.read() return file_userwhile count<3: username=input("name:") userpassword=input("password:") lock_user=read_lock_list(username) if lock_user==username: #输入用户与锁定列表中的用户做对比 print("{0} has already been locaked! ".format(lock_user)) break elif username == user and userpassword==password: print("welcom to my blog!") break count +=1else: if count==3: #如果计数为3的话证明该用户被锁定,因此将该用户加入到锁定列表中 write_lock_list(username) print("{0} has already been locaked! ".format(username))

转载于:https://www.cnblogs.com/mahaigang/p/9851431.html

最新回复(0)