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)