Python定时任务

2020-03-07 17:00:57 浏览数 (1)

pip install apscheduler

python:

代码语言:javascript复制
from apscheduler.schedulers.background import BackgroundScheduler


def tick():
    print('aaa')


scheduler = BackgroundScheduler()
scheduler.add_job(tick, 'interval', seconds=3)  # 间隔3秒钟执行一次
scheduler.start()

print('OK')
while True:
    time.sleep(2000)

0 人点赞