打开菜单:定时任务
第一步:新建任务
第二步:输入任务名称,
命令为:task?文件名称
(如果是根目录,直接写文件名称)
举例:
把依赖先安装好,
获取 下个节假日.py?代码
import requests
import json
import notify
title = "下个节假日"
dateurl = 'https://date.appworlds.cn/next'
daysurl = 'https://date.appworlds.cn/next/days'
holiday = requests.get(dateurl)
daysRes = requests.get(daysurl)
desc = json.loads(holiday.text)
res = json.loads(daysRes.text)
daytime = desc['data']['date']
dayname = desc['data']['name']
Remain = res['data']
info = f"""
下个节假日是{Remain}天后的{dayname}({daytime})
"""
print(info)
notify.send(title, info)