列出指定日期范围所有的天数

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

你可能感兴趣的:(pandas学习,python)