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) #输出结果 #55
本博客内容已全部迁移到我的个人网站 木子窗明(www.muzicm.cn),以后都只会在我的个人网站上首发博客,详情请查看我的个人网站。