[Tutor] formatting datetime.timedelta to "HH:MM:SS"

spir denis.spir at gmail.com
Wed Dec 11 22:15:28 CET 2013


On 12/11/2013 02:55 PM, Jignesh Sutar wrote:
> Thanks Mark,
>
> print('%02d:%02d:%04d' % (now.hour, now.minute, now.year))
>
>
> That works for;
> now = datetime.now()
>
> but not for;
> exe_time = endTime-startTime

Yes, because exe-time is not a ate, a point in time, but a time delta (a 
difference), thus does not hold the same attributes. Write out dir() on 'now' 
and on 'exe_time' to get more info. [dir() tells you about what info an object 
knows, and what methods it understands).]

Denis


More information about the Tutor mailing list