您能告诉我如何在 Win32 和 Linux 上的 Python2.6 中获得高精度 sleep 功能吗?
最佳答案
您可以在 sleep()
中使用 float :
The argument may be a floating point number to indicate a more precise sleep time.
所以
time.sleep(0.5)
会睡半秒。
然而,在实践中, sleep 的精度不太可能超过毫秒,因为操作系统通常只支持毫秒 sleep ,而且非常短的时间很快就会变得不可靠。
关于Python:高精度 time.sleep,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1211806/