Answers for "python try for x seconds"

4

python wait for x seconds

import time
x = 1 # Put in whatever seconds you want it to wait
time.sleep(x)
Posted by: Guest on July-19-2020
0

how to make python do something every x seconds

import sched, time
s = sched.scheduler(time.time, time.sleep)
def do_something(sc): 
    print("Doing stuff...")
    # do your stuff
    s.enter(60, 1, do_something, (sc,))

s.enter(60, 1, do_something, (s,))
s.run()
Posted by: Guest on April-16-2021

Python Answers by Framework

Browse Popular Code Answers by Language