How to get delta time in python? Python provide time module, as my favourite way to get delta / elapse time, of course, depends on what you need, to get simple hour-minute-seconds is what i usually do taking user normal actions, like time taken running scripts, batching, clicking buttons and navigate between tabs, or buttons.
startTime = time.time()
# doing blah… blah…
# whatever actions we do in here
elapsedTime = time.gmtime(time.time() – startTime)
strTime = time.strftime("%H:%M:%S", elapsedTime)
print "action taken in %s" % strTime
Do you have a second?
Human usually only care about hour-minute-seconds, because it’s how we communicate right?
People use second to measure time, at least. “How long does it takes to backup?”, “Do you have a second?”, we talk in second, the smallest notion of time in daily human communication.
Pyhton time module works well for this purpose.