zoukankan      html  css  js  c++  java
  • (Py练习)输入某年某月判断天数

    # 输入某年某月,判断这一天是这一年的第几天
    year = int(input("year:
    "))
    month = int(input("month:
    "))
    day = int(input("day:
    "))
    
    months = (0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334)
    if 0 < month <= 12:
        sum = months[month - 1]
    else:
        print('Date Error
    ')
    sum += day
    leap = 0
    # 判断是否为闰年
    # 判断标准是:1、能被4整除且不能整除100;2、能整除400
    # and 优先级高于 or
    if (year % 400 == 0) or (year % 4 == 0) and (year % 100 != 0):
        leap = 1
    if (leap == 1) and (month > 2):
        sum += 1
    print(f'it is rhe the %dth day.' % sum)
    
    
  • 相关阅读:
    git
    uniapp
    laravel
    laravel
    js
    js -上传文件获取名字赋值
    laravel
    持续集成
    持续集成
    持续集成
  • 原文地址:https://www.cnblogs.com/pteromyini/p/12374855.html
Copyright © 2011-2022 走看看