如何在 Python 中进行时间延迟

发布于 2022-02-17 09:45:11

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

关注者
0
被浏览
74
1 个回答
  • 面试哥
    面试哥 2022-02-17
    为面试而生,有面试问题,就找面试哥。
    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).
    


知识点
面圈网VIP题库

面圈网VIP题库全新上线,海量真题题库资源。 90大类考试,超10万份考试真题开放下载啦

去下载看看