在 Python 中安排一个简单的通知脚本每小时运行一次



我是Python的新手。

我刚刚编写了这个简单的脚本,在我的桌面上打印一条消息:

from plyer import notification
notification.notify(
title="HI MATTEO!",
message="Here's the notification to be sent every hour!",
timeout=10
)

这是通知的屏幕截图

我想知道是否有办法每小时(或在给定时间(运行此通知

非常感谢

马泰奥·福萨蒂

您应该查看schedule包(https://pypi.org/project/schedule/(。

然后,运行如下操作:

schedule.every().hour.do(my_notification)
...
while True:
schedule.run_pending()
time.sleep(1)

最新更新