문제

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]
도움이 되었습니까?

해결책

range(startDate.year, endDate.year+1)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top