Created
February 20, 2018 15:50
-
-
Save TAJD/054c7f9d703cad473072c21634445193 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
class Timer: | |
"""Class to assist with timing functions. | |
Start timing with | |
```my_timer = Timer()``` | |
And then get the time with | |
``` time_get = my_timer.get_time_hhmmss()``` | |
And then restart timer with | |
```my_timer.restart()```""" | |
def __init__(self): | |
self.start = time.time() | |
def restart(self): | |
self.start = time.time() | |
def get_time_hhmmss(self): | |
end = time.time() | |
m, s = divmod(end - self.start, 60) | |
h, m = divmod(m, 60) | |
time_str = "%02d:%02d:%02d" % (h, m, s) | |
return time_str |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment