0
Method to suspend operation
I need to a function in python to execute my code but after a specific amount of time, how can I do it?
2 ответов
+ 1
There is an easier method:
import time
def printer():
print("hi there!")
time.sleep(5) # sleeps for 5 seconds
printer()
Output:
# five second wait
hi there!
0
from threading import Timer
def hello():
print ("hello")
t = Timer(5.0, hello)
t.start()
Though you'll most likely get "Time exceeded" in SoloLearn sandbox.