def time_increase(begin_time,days):
ts = time.strptime(str(begin_time),"%Y-%m-%d")
ts = time.mktime(ts)
dateArray = datetime.datetime.utcfromtimestamp(ts)
date_increase = (dateArray+datetime.timedelta(days=days)).strftime("%Y-%m-%d")
print("日期:{}".format(date_increase))
return date_increase
if __name__ == "__main__":
for i in range (1,8):
time_increase('2019-06-10',i)
----------
输出:
日期:2019-06-10
日期:2019-06-11
日期:2019-06-12
日期:2019-06-13
日期:2019-06-14
日期:2019-06-15
日期:2019-06-16