小编典典

如何在 Python 中进行时间延迟

python

我想知道如何在 Python 脚本中设置时间延迟。


阅读 278

收藏
2022-01-23

共1个答案

小编典典

import time
time.sleep(5)   # Delays for 5 seconds. You can also use a float value.

这是另一个大约每分钟运行一次的示例:

import time
while True:
    print("This prints once a minute.")
    time.sleep(60) # Delay for 1 minute (60 seconds).
2022-01-23