2018.09.20python作业

用户登入,永久锁定锁定,3次黑名单
name=input('please your name: ')
# pwd=input('please your password: ')
with open('黑名单.txt',mode='rt',encoding='utf-8') as a :##

for msg in a:

if name==msg.strip('\n'):
print('该用户已经被锁定')
break

with open("用户数据库.txt",mode='rt',encoding='utf-8') as b:
for info in b:
n,p=info.strip('\n').split(':')
if name == n:
count=0
while True:
pwd = input('please your password: ')
if pwd==p:
print("login successful")
break
if count==2:
print('用户锁定')

with open('黑名单.txt',mode='at',encoding='utf-8')as x:
x.write(name)
break
else:
print("密码错误")
count+=1



else:
print("用户不存在")

posted on 2018-09-20 23:34  撩与诗人  阅读(144)  评论(0编辑  收藏  举报