[英]How can I make Python run at a specific time everyday and make it repeat every hour?
I made a Python script to remind me to drink water every hour.我做了一个 Python 脚本来提醒我每小时喝水。 My code is:
我的代码是:
import time
import plyer
from plyer import notification
if __name__ == "__main__":
while True:
plyer.notification.notify(
title="Go and Drink Water!",
message="You need to drink at least 3.5 litres of water Everyday. Being Dehydrated can decrease Brain Function and Energy levels.",
app_icon="C:\\Users\\(My username)\\(location of icon)",
timeout=10,
)
time.sleep(60 * 60)
I put the python path and this script's path in a.bat file and made it run everyday at 8:35am using Task Scheduler.我将 python 路径和此脚本的路径放在 a.bat 文件中,并使用任务计划程序使其每天早上 8:35 运行。 It did run at 8:35am but it didn't repeat.
它确实在上午 8 点 35 分运行,但没有重复。 Can anyone point out what I am doing wrong or suggest a better method?
谁能指出我做错了什么或提出更好的方法?
use python APScheduler module: https://apscheduler.readthedocs.io/en/stable/userguide.html#code-examples使用 python APScheduler 模块: https://apscheduler.readthedocs.io/en/stable/userguide.html#code-examples
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.