Python的time.sleep()语法
time.sleep(secs)
示例:在Python中使用sleep()函数
1、import time
2、time.sleep(5)
实例代码演示:
import time
print("Welcome to guru99 Python Tutorials")
time.sleep(5)
print("This message will be printed after a wait of 5 seconds")输出结果:
Welcome to guru99 Python Tutorials This message will be printed after a wait of 5 seconds
另外time.sleep()函数幕后使用的是操作系统的sleep()函数,因此会有一些限制。例如,在一个标准的Windows中,可以sleep的最小时间间隔是10-13毫秒。