python小小定时器

吃可爱长大的小学妹 提交于 2019-12-13 03:51:49

import schedule
import time
#引入schedule和time模块
def job():
print(“I’m working…”)
#定义一个叫job的函数,函数的功能是打印’I’m working…’
schedule.every(2).seconds.do(job) #每2s执行一次job()函数(job函数是需要执行的函数体)

while True:
schedule.run_pending()
time.sleep(1)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!