这个问题已经有解答了: 如何让我的Python程序休眠50毫秒?
这个问题已经有解答了:
如何让我的Python程序休眠50毫秒?
我该如何在Python脚本中设置时间间隔?
使用time模块中的sleep()方法。它可以接受浮点数参数来表示子秒分辨率。
time
sleep()
from time import sleep sleep(0.1) # Time in seconds
这会延迟2.5秒:
import time time.sleep(2.5)
这是另一个例子,在这里某些东西大约每分钟运行一次:
import time while True: print("This prints once a minute.") time.sleep(60) # Delay for 1 minute (60 seconds).
用户名或电子邮箱地址
密码