题目:输入某年某月某日,判断这一天是这一年的第几天?
分析:以3月5日为例,应该先把前两个月的加起来,然后再加上5天即本年的第几天,特殊 情况,闰年且输入月份大于3时需考虑多加一天。dateType= input('请输入年月日的格式为:yyyymmdd: ')y = int(dateType[:4])m = int(dateType[5:6])d = int(dateType[7:])rn = Falseif (y%100 == 0 and y%400 == 0) or y%4 ==0: rn = Trueif rn == True: mo = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]else: mo = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]days = 0for i in range(1,m): days += mo[i-1]print('这是今年的第 %s 天'%(days+d))