如何在 Python 中延迟时间? [英] How can I make a time delay in Python?
本文介绍了如何在 Python 中延迟时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何在 Python 脚本中设置时间延迟.
I would like to know how to put a time delay in a Python script.
推荐答案
import time
time.sleep(5) # Delays for 5 seconds. You can also use a float value.
这是另一个大约每分钟运行一次的示例:
Here is another example where something is run approximately once a minute:
import time
while True:
print("This prints once a minute.")
time.sleep(60) # Delay for 1 minute (60 seconds).
这篇关于如何在 Python 中延迟时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文