python3学习---登录小程序

# 登陆小程序
# author:Test_lin

import datetime

dict_lin = {'Test_lin': 'Az12345 ', 'Test': 'AA123456'}
today = datetime.date.today()
count = 0
while count < 3:
    count+=1
    username = input('请输入用户名:')
    password = input('请输入密码:')
    if username in dict_lin :
        if password == dict_lin.get(username):
            print('%s 欢迎登录,今天的日期是 %s 。'%(username, today))
            break
        else:
            print('账号密码有误!')
    elif username.strip() == '' or password.strip() == '':  #账号密码为空判断,且账号为空不计次数
        print('账号或密码不能为空!')
        count-=1

    else:
        print('账号密码有误!')
else:
    print('\n')
    print('账号密码错误3次,请联系管理员!')

 

posted @ 2018-08-28 16:11  A_Life  阅读(307)  评论(0编辑  收藏  举报