Answer the question
In order to leave comments, you need to log in
How to make a timer in python?
Python 2.7. Debian.
The program is in an eternal loop.
How to make print happen after 10 seconds?
But without stopping the cycle, other procedures also want to work there.
On arduino it was done like this:
timing = millis();
void loop() {
if (millis() - timing > 10000){
timing = millis();
Serial.println ("10 seconds");
}
}
Answer the question
In order to leave comments, you need to log in
import time
timing = time.time()
while True:
if time.time() - timing > 10.0:
timing = time.time()
print("10 seconds")
Yes, you can do the same:
from time import monotonic
t = monotonic()
while True:
if monotonic() - t > 10:
t = monotonic()
print('tick')
import time
print("О чём вам напомнить?")
text = str(input())
print("Через сколько минут?")
local_time = float(input())
local_time = local_time * 60
time.sleep(local_time)
print(text)
from threading import Timer
from time import sleep
def hello():
print("Hello user!")
def bye():
sleep(5)
print("Bye...bye...")
while 1:
timer = Timer(3, hello)
timer.start()
bye()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question