import datetime
start_time = '2021-02-01'
end_time = '2021-03-13'
fmt = '%Y-%m-%d'
start = datetime.datetime.strptime(start_time,fmt)
end = datetime.datetime.strptime(end_time,fmt)
while start <end:#缺少第一天
#日期增加一天
start+=datetime.timedelta(days=1)
#计算相差日数
#interval=int((end-start).days) +1
#计算相差小时数
#interval=int((end-start).days*24+(end-start).seconds/60/60) +1
#计算相差分钟数据
#interval=int((end-start).days*24*60/10+(end-start).seconds/60/10) +1
#转换成字符串
print(start.strftime(fmt))
fmt = '%Y-%m-%d'
def day_range():
begin=datetime.datetime.strptime(start,fmt)
end=datetime.datetime.strptime(end,fmt)
delta=datetime.timedelta(days=1)
interval=int((end-begin).days) +1
for i in range(0,interval,1):
time = begin+delta*i
print(time)