strptime in 2.3.3

Glawster andywil at nortelnetworks.com
Fri Mar 26 13:44:24 CET 2004


"Holger Joukl" <Holger.Joukl at LBBW.de> wrote in message news:<mailman.394.1080220394.742.python-list at python.org>...
> Andy writes:
> Folks,
> 
> I am parsing a list of directories that have a name format
> 'YearWeekNoDay', using the follwoing code
> 
>             print list dir[j]
>             print "%s" % (time.strptime (list dir[j], '%Y%U%w'))
>             ttuple = time.strptime (list dir[j], '%Y%U%w')
>             year   = ttuple[0]
>             month  = ttuple[1]
>             day    = ttuple[2]
>             print day, month, year
> 
> I get the following output:
> 
> 2004123
> (2004, 1, 1, 0, 0, 0, 2, 1, -1)
> 1 1 2004
> 
> 2004124
> (2004, 1, 1, 0, 0, 0, 3, 1, -1)
> 1 1 2004
> 
> ====
> 
> Are you sure you are using the correct format string?
> %U is week number of year [00-53], so I am not sure what happens
> if you combine that with a day of month that surely is not in this week..
> 
> Cheers
>  Holger
> 

%w (lower case) is day of the week 0 (Sunday) to 6



More information about the Python-list mailing list