4
How to make a timer in while? I would like to run a while, and do something, e.g. a
print "hello"
run print "hello" for 1 hour for example.
4
How to make a timer in while? I would like to run a while, and do something, e.g. a
print "hello"
run print "hello" for 1 hour for example.
3
You can do it like this:
import time
end_time = time.time() + 10
countTimer = 0
sleepTime = 0.500
while time.time() < end_time:
time.sleep(sleepTime)
countTimer += sleepTime
print('hello, ja passaram {} secs'.format(countTimer))
Change the 10 by 3600 for a 1hour. You can remove the Sleep, but the program will get very heavy
Browser other questions tagged python loop
You are not signed in. Login or sign up in order to post.
Perfect Miguel, that’s right! What if I wanted to show that this was being executed? Running the above code does not notice on the screen that hello is being printed as time goes by, due to the fact that nothing changes. Let’s say something like this: 500ms past it shows one: 500ms have passed. How could you do?
– Allan
Ha ok I’ll do it, I get it
– Miguel
Made on top @Allan
– Miguel
Miguel ball show, incredible Kra ;-) congratulations!
– Allan
You’re welcome @Allan. obgado
– Miguel