编写的登陆接口2

dic ={
    'egon1':{'password':'123','count':0},
    'egon2':{'password':'234','count':0},
    'egon3':{'password':'345','count':0},
}
while True:
    name = input('username:')
    if not name in dic:
        print("用户不存在")
        continue
    if dic[name]['count']>2:
        print('尝试次数过多,锁定')
        continue
    password = input('password:')
    if password == dic[name]['password']:
        print('登陆成功')
        break
    else:
        print('用户名或密码错误')
        dic[name]['count']+=1
        print(dic[name]['count'])

拷贝别人的,联系感觉比用txt文档方便

posted @ 2018-02-22 14:02  蓝色巨人_2008  阅读(49)  评论(0)    收藏  举报