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

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

代码

"""判断天数"""

def num(year,month,date):

days=0

    if year%4==0 and year%100!=0:

for iin range(0,month-1):

days=days+list1[i]

days=days+date

else:

for iin range(0,month-1):

days=days+list2[i]

days=days+date

return days

if __name__ =='__main__':

list1=[31,29,31,30,31,30,31,31,30,31,30,31]

list2=[31,28,31,30,31,30,31,31,30,31,30,31]

year=int(input('请输入年份:'))

month=int(input('请输入月份:'))

date=int(input('请输入日期:'))

days=num(year,month,date)

print('天数是:%d'%days)

你可能感兴趣的:(Python笔记——输入某年某月某日,判断这一天是这一年的第几天)