# -*- coding:utf-8 -*-
__author__ = 'yangxin_ryan'
import calendar
import datetime
class TimeFunc(object):
def time_12_month(self):
"""
计算近12个月的天数
:return:
"""
now_year = datetime.datetime.now().year
now_month = datetime.datetime.now().month
month_list = []
year_list = []
for i in range(12):
temp_month = now_month + i
if 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 + 1
year_list.append(temp_year)
else:
Python计算近12个每个月的天数
本文介绍如何使用Python计算并列出最近12个月每个月的天数,涵盖日期处理和循环计算的关键步骤,适用于数据分析和日历应用。
摘要由CSDN通过智能技术生成