Funktionsprüfung
Python 3 (ideone)
Implementieren Sie Folgendes.
--Starten Sie ab dem Enddatum
Es scheint timedelta () von datetime zu verwenden. https://docs.python.jp/3/library/datetime.html
code
http://ideone.com/maiFmH
from datetime import datetime as dt
from datetime import timedelta
ENDSTR = "20170202"
STARTSTR = "20161031"
INTERVAL_DAY = 13
enddt = dt.strptime(ENDSTR, '%Y%m%d')
startdt = dt.strptime(STARTSTR, '%Y%m%d')
wrkdt = enddt
while True:
print(wrkdt)
if wrkdt < startdt:
break
wrkdt = wrkdt + timedelta(days=-INTERVAL_DAY)
run
2017-02-02 00:00:00
2017-01-20 00:00:00
2017-01-07 00:00:00
2016-12-25 00:00:00
2016-12-12 00:00:00
2016-11-29 00:00:00
2016-11-16 00:00:00
2016-11-03 00:00:00
2016-10-21 00:00:00
Recommended Posts