Python定时任务
shell
pip install apscheduler
pip install apscheduler
python:
python
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)
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)