title: Python Elapsed Time as Days, Hours, Minutes, Seconds
body: <p>I would like to measure the execution time of some piece of code in <strong>days</strong>, hours, minutes and seconds. 
  This is what I have so far:</p>
  
  <pre class="lang-py prettyprint-override"><code>import time
  start_time = time.time()
  
  # some code
  
  elapsed = time.strftime("%H:%M:%S", time.gmtime(time.time() - start_time))
  print(f"Took: {elapsed}")
  </code></pre>
  
  <p>The problem is that if the code that I am measuring takes longer than 24h, the time displayed overflows and starts from zero again. I would like something like this:</p>
  
  <pre><code># Example: 12 hours and 34 minutes should be printed as 
  &gt; Took: 12:34:00
  
  # Example: 26 hours and 3 minutes should be printed as 
  &gt; Took: 1:02:03:00
  </code></pre>