计算2020-06,2021-08类似的日期之间缺少的月份
```# 计算a,b之间缺少的月份
def get_month_list(a, b):
a_list = a.split('-')
b_list = b.split('-')
a_year = int(a_list)
a_month = int(a_list)
b_year = int(b_list)
b_month = int(b_list)
month_list = []
for i in range(a_year, b_year + 1):
for j in range(1, 13):
if i == a_year and j < a_month:
continue
if i == b_year and j > b_month:
continue
month_list.append(str(i) + '-' + str(j))
return month_list
a = "2020-06"
b = "2021-08"
print(get_month_list(a, b))
``` datautil.rrule(rrule.MONTHLY, dtstart = date1, until = date2).count()
导入 rrule
页:
[1]