试试这个:
start_date = '01-03-2019' # Considering 03 is the month, 01 is the day
end_date = '15-03-2019' # Considering 03 is the month, 15 is the day
start_date = [int(i) for i in start_date.split("-")]
end_date = [int(i) for i in end_date.split("-")]
days = 'monday' , 'tuesday'
from datetime import timedelta, date
start_date = date(start_date[-1], start_date[1], start_date[0])
end_date = date(end_date[-1], end_date[1], end_date[0])
# Now check in the range of start_date and end_date with condition .weekday() Monday is 0 and Tuesday is 1.
def daterange(start_date, end_date):
for n in range(int ((end_date - start_date).days)):
yield start_date + timedelta(n)
for single_date in daterange(start_date, end_date):
if single_date.weekday() ==0:
print("Monday : ", single_date)
if single_date.weekday() == 1:
print("Tuesday : ", single_date)