FW: (no subject)
Leeds, Mark
mleeds at mlp.com
Thu Jun 5 19:12:05 EDT 2003
I have another date question :
Now I have dates that are of the form
2/14/1980 so
I tried to read them in using
Temptime = time.strptime(filedate,"%m" + "//" + "%d" + "//" + "%Y") But
I get some weird error like format mismatch.
Could it be because the date is 2/14 instead of 02/14 ?
This will be my last question about dates.
mark
-----Original Message-----
From: Skip Montanaro [mailto:skip at pobox.com]
Sent: Thursday, June 05, 2003 3:08 PM
To: Leeds, Mark
Cc: python-list at python.org
Subject: Re: (no subject)
Mark> i have a date, say as a string 26Nov2002 and i want to convert
it
Mark> to a string 20021126.
Python has a time module with strptime (parse) and strftime (format)
functions.
>>> import time
>>> t = time.strptime("26Nov2002", "%d%b%Y")
>>> t
(2002, 11, 26, 0, 0, 0, 1, 330, -1)
>>> time.strftime("%Y%m%d", t)
'20021126'
Skip
More information about the Python-list
mailing list