本文主要是介绍Python计算近12个每个月的天数,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
# -*- coding:utf-8 -*-
__author__ = 'yangxin_ryan'
import calendar
import datetimeclass TimeFunc(object):def time_12_month(self):"""计算近12个月的天数:return:"""now_year = datetime.datetime.now().yearnow_month = datetime.datetime.now().monthmonth_list = []year_list = []for i in range(12):temp_month = now_month + iif int(temp_month / 12) == 2 or (int(temp_month / 12) == 1 and temp_month % 12 != 0):month_list.append(temp_month % 12)temp_year = now_year + 1year_list.append(temp_year)else:month_list.append(temp_month)year_list.append(now_year)print(month_list)print(year_list)result = []for j in range(12):
这篇关于Python计算近12个每个月的天数的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!