Creating a range of dates in Python

后端 未结 20 2093
栀梦
栀梦 2020-11-22 11:02

I want to create a list of dates, starting with today, and going back an arbitrary number of days, say, in my example 100 days. Is there a better way to do it than this?

20条回答
  •  不思量自难忘°
    2020-11-22 11:30

    If there are two dates and you need the range try

    from dateutil import rrule, parser
    date1 = '1995-01-01'
    date2 = '1995-02-28'
    datesx = list(rrule.rrule(rrule.DAILY, dtstart=parser.parse(date1), until=parser.parse(date2)))
    

提交回复
热议问题