Difference Between Two datetimes

W. eWatson wolftracks at invalid.com
Mon Dec 28 22:51:31 CET 2009


This is quirky.

 >>> t1=datetime.datetime.strptime("20091205_221100","%Y%m%d_%H%M%S")
 >>> t1
datetime.datetime(2009, 12, 5, 22, 11)
 >>> type(t1)
<type 'datetime.datetime'>
 >>>
t1:  2009-12-05 22:11:00 <type 'datetime.datetime'>

but in the program:
    import datetime

    t1=datetime.datetime.strptime("20091205_221100","%Y%m%d_%H%M%S")
    print "t1: ",t1, type(t1)

produces
t1:  2009-12-05 22:11:00 <type 'datetime.datetime'>

Where did the hyphens and colons come from?




More information about the Python-list mailing list