python第一天练习题
div={ 'list1':{'password':'123456'},'list2':{'password':'123456'},
'list3':{'password':'123456'},
}
f = open("black_user.txt",'r')
lock_file = f.readlines()
f.close()
count=0
count1=0
while True:
name_input=input("please input name:")
if count == 3:
print("用户名输入次数到达限制")
break
ifnot name_input in div:
print("用户名错误")
count +=1
ifname_input in lock_file:
print("户名已锁定,暂停使用!")
exit()
if name_input in div:
count -=2
password_input=str(input("please input password:"))
if password_input == div['password']:
print ("密码成功")
break
else:
print("密码错误")
count1 +=1
if count1 == 2:
print("您输入的密码错误次数已达3次,将锁定您的账户!")
f = open('black_user', 'w')
f.write('%s'%name_input)
f.close()
break
页:
[1]