“’做一个定时通知上下班打卡的,以防忘了打卡‘”
在IDLE上运行的(只需要pip install apscheduler),在pycharm上运行需要手动去python解释器里下载APScheduler包,否则会报找不到模块的错误!
import time
from datetime import datetime
from apscheduler.schedulers.blocking import BlockingScheduler
def my_job():
print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())))
def my_job2():
print("天气之子正在热映")
def my_job3():
print("双枪会给出答案!!!")
sched = BlockingScheduler()
sched.add_job(my_job, 'interval', seconds=5)
sched.add_job(my_job2, 'date', run_date=datetime(2021, 10, 22, 15, 50, 00))
sched.add_job(my_job3, 'cron',day_of_week='mon-sat', hour = 15,minute = 50,second = 00)
sched.start()
sched.shutdown(wait=False)
参数说明:
def my_job() :为作