FW: (no subject)

W Isaac Carroll icarroll at pobox.com
Fri Jun 6 04:02:45 EDT 2003


Leeds, Mark wrote:
> 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 ?

On my system (Python 2.2 on Mandrake Linux) the following works just fine:

     Temptime = time.strptime(filedate, "%m/%d/%Y")

The forward slash has no special meaning, so doubling it is not correct. 
Also, there's no need to split the string up and concatenate the pieces. 
Just put it all as one string.

> This will be my last question about dates.

TTFN






More information about the Python-list mailing list