This question already has answers here:
How do I get my Python program to sleep for 50 milliseconds?
                                
                                    (4个答案)
                                
                        
                                5个月前关闭。
            
                    
我想知道如何在Python脚本中放置时间延迟。

最佳答案

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).

关于python - 如何在Python中进行时间延迟? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54508926/

10-13 07:26
查看更多