1import time
2
3t0 = time.time()
4code_block
5t1 = time.time()
6
7total = t1-t0
1from timer import Timer
2t = Timer()
3t.start()
4# Run stuff here.
5t.stop()
1import time
2thistime = time.time()
3# Here's an idea!
4def CountTime():
5 while(True):
6 time.sleep(1)
7 print(thistime)
8CountTime()
1#import time module:
2import time
3#module has various attributes:
4dir(time)
5[..., 'localtime', 'mktime', 'sleep', 'sleep_ms', 'sleep_us', 'ticks_add', 'ticks_cpu', 'ticks_diff', 'ticks_ms', 'ticks_us', 'time']
6
7#default expression is in seconds with zero being start of runtime
8secFromStart = time.time()