python 计算周的范围时间
week_len = ["", 2, 3, 4] week_time_list = ["2021-09-06", "2021-09-27"] ne = [] print(week_time_list) for j in range(0, len(week_len)): c = ne[-1] if len(ne) > 0 else week_time_list[0] end_date = datetime.strptime(c, '%Y-%m-%d') now_date_end = timedelta(days=7) s = end_date + now_date_end result_time = s.strftime('%Y-%m-%d') ne.append(result_time) ne.pop() ne.insert(0, week_time_list[0]) print(ne) gf = [ (item, datetime.strftime(datetime.strptime(item, '%Y-%m-%d') + timedelta(days=7), '%Y-%m-%d')) for item in ne] print(gf)