返回顶部
首页 > 资讯 > 后端开发 > Python >Python – How to dela
  • 881
分享到

Python – How to dela

Pythondela 2023-01-31 01:01:19 881人浏览 泡泡鱼

Python 官方文档:入门教程 => 点击学习

摘要

In python, you can use time.sleep(seconds) to make the current executing Python program to sleep or delay a few sec

In python, you can use time.sleep(seconds) to make the current executing Python program to sleep or delay a few seconds.

import time

time.sleep(1) # delays for 1 seconds
time.sleep(10) # delays for 10 seconds
time.sleep(60) # delays for 1 minute
time.sleep(3600) # delays for 1 hour

Full example.

test_delay.py

import time

def main():

    while True:
        print("DateTime " + time.strftime("%c"))
        time.sleep(1) # delays for 1 seconds

if __name__ == '__main__':
    main()

Output

DateTime 09/22/15 18:03:42
DateTime 09/22/15 18:03:43
DateTime 09/22/15 18:03:44
DateTime 09/22/15 18:03:45
DateTime 09/22/15 18:03:46
DateTime 09/22/15 18:03:47
#...

--结束END--

本文标题: Python – How to dela

本文链接: https://lsjlt.com/news/184598.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作