range(startDate.year, endDate.year+1)
Get all years between two dates in python
Question
Let say that I have this code:
import sys
from datetime import datetime
startDate = datetime.strptime(sys.argv[1], '%d.%m.%Y') # e.g. 05.06.2001 DD.MM.YYYY
endDate = datetime.strptime(sys.argv[2], '%d.%m.%Y') # e.g. 25.05.2005
How to get all the years between these two dates, including start and end year, like
[2001, 2002, 2003, 2004, 2005]
La solution
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow