Title says it all, is it possible to make python sleep for less than a second? WORKS:

import time
print ("foo")
time.sleep(0.2) #talking about the value of the time
print ("bar")

If not, then is there any other way? Thanks Using python 3.2.2 EDIT: Thanks guys, I'm pretty sure I have tried the above code before and it didn't work. Oh well... sorry for your waste if time. It worked now and I upgraded to 3.3

有帮助吗?

解决方案

Based on the time.sleep() documentation:

The actual suspension time may be less than that requested because any caught signal will terminate the sleep() following execution of that signal’s catching routine. Also, the suspension time may be longer than requested by an arbitrary amount because of the scheduling of other activity in the system.

So it works but there are no guarantees.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top