Contrôle de fonctionnement
Python 3 (ideone)
Mettez en œuvre ce qui suit.
Il semble utiliser timedelta () de datetime. 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