On Sun, Sep 7, 2008 at 1:17 PM, greg whittier <[EMAIL PROTECTED]> wrote:

>> # program to test str... functions
>> import datetime
>
> Are you sure you didn't do "from datetime import datetime"?

or "import time" ?

>> ...
>> # format conversion of date+time
>> dt1 = datetime.strptime("20080421_101145", "%Y%m%d_%H%M%S")
>
> I don't see how this works as written because the datetime module doesn't
> have a strptime function.
>>
>> print "dt1: ",dt1
>> other = dt1.strftime("%Y%m%d_%H%M%S")  <-- fails, line 11
>> print other.replace(" ", "")
>>
>> Results:
>> dt1:  (2008, 4, 21, 10, 11, 45, 0, 112, -1)

Looks to me like you are confusing the time and datetime modules.
time.strptime() will return a time struct;
datetime.datetime.strptime() returns a datetime.datetime.

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to