I was searching for a usleep() function in Python 2.7.
Does anybody know if it does exist, maybe with another function name?
You Can Be Precise Make your time delay specific by passing a floating point number to sleep() . from time import sleep print("Prints immediately.") sleep(0.50) print("Prints after a slight delay.")
If you've got a Python program and you want to make it wait, you can use a simple function like this one: time. sleep(x) where x is the number of seconds that you want your program to wait.
To sleep for milliseconds with this method, simply use a fractional number. To sleep for 400 milliseconds, for example, use time. sleep(0.4), use time for 60 milliseconds sleep(0.06), for example.
Since usleep
generally means you want to delay execution for x microseconds, you must divide the seconds value by 1000000.
import time time.sleep(seconds/1000000.0)
time.sleep()
takes seconds as a parameter.
http://docs.python.org/library/time.html#time.sleep
import time usleep = lambda x: time.sleep(x/1000000.0) usleep(100) #sleep during 100μs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With