标签:for 题目 print soft nbsp 年月日 分析 type mil
题目:输入某年某月某日,判断这一天是这一年的第几天?dateType= input('请输入年月日的格式为:yyyymmdd: ')
y = int(dateType[:4])
m = int(dateType[5:6])
d = int(dateType[7:])
rn = False
if (y%100 == 0 and y%400 == 0) or y%4 ==0:
rn = True
if 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 = 0
for i in range(1,m):
days += mo[i-1]
print('这是今年的第 %s 天'%(days+d))标签:for 题目 print soft nbsp 年月日 分析 type mil
原文地址:http://blog.51cto.com/853056088/2155841