python 计算两个日期直间连续日期列表

import time
from datetime import datetime
def getBetweenDay(begin_date,end_date):
    date_list = []
    begin_date = datetime.strptime(begin_date, "%Y-%m-%d")
    end_date = datetime.strptime(end_date, "%Y-%m-%d")
    while begin_date <= end_date:
        date_str = begin_date.strftime("%Y-%m-%d")
        date_list.append(date_str)
        begin_date += timedelta(days=1)
    return date_list

res_list = getBetweenDay('2020-01-01','2020-03-09')

posted @ 2020-07-09 09:37  cup_leo  阅读(1089)  评论(0编辑  收藏  举报