python 用户登录系统 和 计算天数

26 阅读1分钟
# 用户名、密码、黑名单
users = {
    '小红':{'name':'小红', 'password':'123', 'status':True},
    'mia':{'name':'mia', 'password':'456', 'status':True},
    'jack':{'name':'jack', 'password':'789', 'status':False},
}
print(users)
for j in range(3):
    user = input('请输入你的用户名:')
    pwd = input('请输入你的密码:')
    if user in users and pwd==users[user]['password'] and users[user]['status']:
        print('登录成功!')
        break
    elif user in users and not users[user]['status']:
        print('账号失效,请联系管理员!')
    elif user in users and pwd!=users[user]['password']:
        print('密码输入错误,请重试!')
    else:
        print('用户不存在,请先注册!')
# 题目要求:输入2024-02-25,输出这一天是这一年的第多少天
# 2023-12-21
date = input('请输入日期:').split('-')
print(date)
year = int(date[0])
month = int(date[1])
day = int(date[2])

days = [0,31,28,31,30,31,30,31,31,30,31,30,31]
if (not year % 4  and year % 100 ) or not year % 400:
    days[2]+=1

result = 0
for i in range(month):
    result += days[i]
result += day
print('这一天是这一年的第%d天'%result)