结果图如下 有提醒标题和提醒的内容
from win10toast import ToastNotifier import time
首先要导入这两个库 如忘记怎么导入的可以看我博客
(66条消息) pycharm 导入库 图文解释(import)_showswoller的博客-CSDN博客
接下来是完整代码
from win10toast import ToastNotifier import time toaster = ToastNotifier() try: print("提醒时间的标题") header = input() print("提醒的内容") text = input() print("多少分钟后提醒") time_min = input() time_min = float(time_min) except:#类似于java中的try catch 用来捕获异常 防止程序中断 header = input("Title of reminder\n") text = input("Message of remindar\n") time_min = float(input("In how many minutes?\n")) time_min = time_min * 60 print("Setting up reminder..") time.sleep(2) print("all set!") time.sleep(time_min)#线程休眠时间 toaster.show_toast(f"{header}", f"{text}", duration=10, threaded=True)#窗体显示内容 while toaster.notification_active(): time.sleep(0.005)