Skip to content Skip to sidebar Skip to footer

Convert A List Of DateTime Objects To String In Python

I have a list of Dates returning Mondays between two dates mondays =[datetime.date(2019, 2, 14), datetime.date(2019, 2, 21)] How do I format this list to %Y%m%d format? Expecting o

Solution 1:

the following will work

[date_obj.strftime('%Y%m%d') for date_obj in mondays]

Output

['20190214', '20190221']

Post a Comment for "Convert A List Of DateTime Objects To String In Python"