Python小代码_8_今天是今年的第几天

import time

date = time.localtime()
print(date)
#time.struct_time(tm_year=2018, tm_mon=2, tm_mday=24, tm_hour=19, tm_min=42, tm_sec=57, tm_wday=5, tm_yday=55, tm_isdst=0) year = date[0]
month = date[1]
day = date[2]
day_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] #判断是否为闰年
if year % 400 == 0 or (year % 4 == 0 and year % 100 != 0):
day_month[1] = 29
if month == 1:
print(day)
else:
print(sum(day_month[0: month - 1]) + day) #输出结果
#
上一篇:常州培训 day7 解题报告


下一篇:tomcat集群和负载均衡的实现(session同步)