• pyhton判断闰年


    闰年判断:可以被100整除不能被4整除和400整除,闰年2月份是29天,其他的2月是28天

    y=int(input("Pls input date: "))
    ly=False
    if ly<9999:
    if ly%100==0:
    if ly%400==0:
    ly=True
    else:
    ly=False
    elif ly%4==0:
    ly=True
    else:
    ly=False

    if ly:
    month_day={1:31,2:29,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31}
    else:
    month_day = {1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}

    m=int(input('Pls input month: '))
    d=int(input('Pls input day: '))
    if m not in month_day:
    print('Month value input error')
    exit(1)
    if d<1 or d>month_day[m]:
    print("day input error")
    exit(1)

    days=0
    for i in range(1,m):
    days+=month_day[i]
    print('this the the %day'%((days+d)))
  • 相关阅读:
    JavaScript 教程
    C#基础实例
    Angularjs实例5
    Angularjs实例4
    Angularjs 数据过滤
    Angularjs实例3
    Angularjs 数据循环
    Angularjs模块
    Angularjs 数据双向绑定
    Angularjs实例应用
  • 原文地址:https://www.cnblogs.com/JacquelineQA/p/13953322.html
Copyright © 2020-2023  润新知