首页 > 其他分享 >输入某年某月某日,判断这一天是这一年的第几天

输入某年某月某日,判断这一天是这一年的第几天

时间:2022-11-08 09:33:48浏览次数:44  
标签:30 第几天 isLeapYear 31 year day 某日 某年某月 Sum

# !/usr/bin/python3

# *_*coding:utf8 *-*
# @Time :2022-11-08
# @Author :jeck
# @Email :
# @File :question4.py

# 输入某年某月某日,判断这一天是这一年的第几天

year = int(input('输入年:'))
month = int(input('输入月:'))
day = int(input('输入日:'))

day_Sum = 0
isLeapYear = False # 是否是闰年。
if year % 4 == 0:
if year % 100 != 0:
isLeapYear = True
elif year % 400 == 0:
isLeapYear = True
else:
isLeapYear = False

Month_day = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

for i in range(month):
day_Sum += Month_day[i]

day_Sum += day
if isLeapYear:
day_Sum += 1

print (day_Sum)

标签:30,第几天,isLeapYear,31,year,day,某日,某年某月,Sum
From: https://www.cnblogs.com/DreamTalk/p/16868053.html

相关文章