0

I am coding a simple game in Python 3 and I need to measure the time passed from one moment to another. Ideally I would like a function that starts measuring and another one which returns the time passed. Is this possible?

  • 2
    Possible duplicate of [Measuring elapsed time with the Time module](https://stackoverflow.com/questions/3620943/measuring-elapsed-time-with-the-time-module) – Mohammad Athar Jun 28 '18 at 15:07
  • Possible duplicate of [Measure time elapsed in Python?](https://stackoverflow.com/questions/7370801/measure-time-elapsed-in-python) – BenG Jun 28 '18 at 15:07

1 Answers1

0

it's pretty simple, using the stdlib time module:

import time
t1 = time.time()
# other code ...
t_diff = time.time() - t1  # time in seconds
Felix
  • 6,131
  • 4
  • 24
  • 44