How would I measure passing seconds using Python? | Sololearn: Learn to code for FREE!

+1

How would I measure passing seconds using Python?

I want to know how long one of my programs will run!

11/13/2016 4:03:40 AM

Erik Johanson

2 Answers

New Answer

+4

try something like this: import time def measure(func, *args): start=time.time() func(*args) return time.time()-start def foo(*args): start, stop=args[0], args[1] for x in range(start, stop): x+=1 print(measure(foo, 0, 10000000)) something like the measure function

+2

import time seconds=0 while True: time.sleep(1) seconds+=1 print(seconds, end='\r')