← Go Back
The first argument of
How to Run Code After a Certain Time
Using the standardthreading.Timer
class:import threading
def f():
print("Hello, world!")
# Execute the function after 3 seconds.
t = threading.Timer(3, f)
t.start()
print("This gets executed before the f() function.")
The first argument of
Timer
indicates the number of seconds within which the function passed as the second argument will be executed.