Printing list of dates starting today
Ari Makela
hauva at arska.org
Mon Sep 1 12:09:13 EDT 2008
On 2008-09-01, Luka Djigas <ldigas at remove_this.gmail.com> wrote:
> please, I need your help. I'm new to python, so I don't know if this
> will seem like a stupid question to some of you ...
There are several ways to do it. Have a look at the documentation
of modules time and datetime. For this exact problem time is the
most straighforward one.
> I have a need to write to a file (or just print on screen, that part
> doesn't matter at this point) a list of dates, starting today. For
> example:
> 02.09.2008. tue
> 03.09.2008. wed
0 hauva at laphroaig:~
$ /usr/bin/python
Python 2.5.2 (r252:60911, Jul 31 2008, 17:31:22)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
>>> DAY = 60 * 60 * 24
>>> today = time.time()
>>> for i in (0, 1, 2, 3):
... t = time.gmtime(time.time() + i * DAY)
... print time.strftime('%d.%m.%Y, %a', t)
...
01.09.2008, Mon
02.09.2008, Tue
03.09.2008, Wed
04.09.2008, Thu
--
Ari Makela late autumn -
hauva at arska.org a single chair waiting
http://arska.org/hauva/ for someone yet to come
-- Arima Akito
More information about the Python-list
mailing list