> > print str(exe_time).split('.')[0]
Sorry, I guess my question was why I can't use something similar to below on exe_time (of type datetime.timedelta)? Rather than doing string manipulation on decimals or colons to extract the same. now = datetime.now() print now.hour print now.minute print now.year On 11 December 2013 12:43, David Robinow <drobi...@gmail.com> wrote: > On Wed, Dec 11, 2013 at 5:55 AM, Jignesh Sutar <jsu...@gmail.com> wrote: > > Hi, > > > > I've googled around extensively to try figure this out assuming it > should be > > straight forward (and it probably is) but I'm clearly missing something. > > > > I'm trying to get the total run time of the program but have the final > time > > being displayed in a particular format. I.e. without the seconds in > > milliseconds decimal points and just to customize it a bit more. > > > > import time > > from datetime import datetime > > startTime = datetime.now() > > time.sleep(5.1564651443644) > > endTime = datetime.now() > > exe_time = endTime-startTime > > > > print type(startTime) > > print type(endTime) > > print type(exe_time) > > > > print "startTime: ", startTime > > print "endTime:", endTime > > print "exe_time: ", exe_time #how to format this to "D Days, HH: MM: SS" > ? > > #exe_time: 0:00:05.156000 > > #desired 0 Days, 0h: 00:m: 05s > > > print str(exe_time).split('.')[0] > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor