gpt4 book ai didi

python - 让 Python 程序等待

转载 作者:太空狗 更新时间:2023-10-29 18:13:33 25 4
gpt4 key购买 nike

我需要让我的 python 程序等待 200 毫秒,然后才能轮询某个描述的输入。例如,在 C# 中,我可以使用 Thread.Sleep() 来实现这一点。在 Python 中执行此操作的最简单方法是什么?

最佳答案

使用Time模块。

例如延迟1秒:

import time
time.sleep(1) # delay for 1 seconds

在你的情况下,如果你想获得 200 毫秒,请改用它:

time.sleep(0.2)

time.sleep 也适用于 float。

关于python - 让 Python 程序等待,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15472707/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com