Why is Python datetime time delta not found?

前端 未结 3 1579
长发绾君心
长发绾君心 2020-12-17 09:40

I am trying to make an array of dates in mmddyyyy format. The dates will start on the current day and then go two weeks into the future. So it all depends on the starting da

3条回答
  •  甜味超标
    2020-12-17 10:11

    You already imported timedelta. You don't need to access it through datetime.

    import time
    from datetime import datetime, date, time, timedelta
    
    dayDates = []
    today = datetime.now()
    dayDates.append(today.strftime("%m%d%Y"))
    for i in range(0,14):
        day = today + timedelta(days=i)
        print day
    

提交回复
热议问题