+ 1
How would I measure passing seconds using Python?
I want to know how long one of my programs will run!
2 Respostas
+ 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')