简体   繁体   中英

Python. Get a list with weeks

I have a range of dates. For instance: from 2020-09-28 until 2020-10-13. And I need to get a list of weeks starting from Mondays with dates. For instance:

[['2020-09-28', '2020-10-04'], ['2020-10-05', '2020-10-11'], ['2020-10-12', ' 2020-10-14 ']

You can use this method to print Weekday,hope it will help

import datetime 
import calendar
def findDay(date):
    for i in date:
        born = datetime.datetime.strptime(i, '%d-%m-%Y').weekday() 
        return (calendar.day_name[born])

  # Driver program 
date = ["24-3-2020"]
print(findDay(date)) 

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM