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?

16th Oct 2017, 7:32 PM
Abdelrahman Hamoda
Abdelrahman Hamoda - avatar
2 Réponses
+ 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!
16th Oct 2017, 9:39 PM
LunarCoffee
LunarCoffee - avatar
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.
16th Oct 2017, 7:48 PM
deFault