> Date: Tue, 4 Jun 2013 14:31:07 -0700
> Subject: How to increment date by week?
> From: [email protected]
> To: [email protected]
>
> Starting on any day/date, I would like to create a one year list, by week
> (start date could be any day of week). Having a numerical week index in
> front of date, ie 1-52, would be a bonus.
> ie, 1. 6/4/2013
> 2. 6/11/2013
> 3. 6/18/2013....etc to # 52.
>
> And to save that result to a file.
> Moving from 2.7 to 3.3
> TIA
YAS:
import datetime
today = datetime.datetime.today()
week = datetime.timedelta(weeks=1)
f=open('output.txt','w')
for i in range(52):
f.write((today+i*week).strftime(str(i+1)+'. %Y-%m-%d\n'))
f.close()
--
http://mail.python.org/mailman/listinfo/python-list