【问题标题】:Python -> reminder not poppingPython - >提醒没有弹出
【发布时间】:2020-11-30 07:25:59
【问题描述】:

我正在一个通知程序上做一个项目,该程序在您编辑它时读取一个 Excel 文件,然后在您设置提醒时发送通知。 代码在这里:

import pandas as pd
import datetime
from plyer import notification


def remind(title, message):
    notification.notify(title=title, message=message, timeout=10)


if __name__ == '__main__':
    while True:
        df = pd.read_excel("./reminder.xlsx")
        for index, item in df.iterrows():
            time = datetime.datetime.now().strftime("%H:%M:%S")
            if time == item['Time']:
                remind(item['Title'], item['Message'])
            else:
                continue

程序运行正常但没有弹出提醒 我正在 win8(64 位)上开发 python 3.7.9

【问题讨论】:

    标签: python-3.x excel pandas reminders


    【解决方案1】:
    from numpy import nan
    import pandas as pd
    import datetime
    from plyer import notification
    import time
    
    
    def notifyMe(title, message,icon):
        notification.notify(
            title=title, 
            message=message, 
            app_icon = icon,
            timeout=10)
    
    
    if __name__ == '__main__':
        
        notifyMe("Hello","We are in together in these tough time","virusicon.ico")
    
        df = pd.read_excel("reminder.xlsx")
        df["Icon"] = df["Icon"].astype(str)  
        df["Heading"] = df["Heading"].astype(str)
        df["Message"] = df["Message"].astype(str)
    
        number_of_rows = len(df.index)
    
        while True:
            flag = True
            for item in range(0,number_of_rows):
                now = datetime.datetime.strptime(datetime.datetime.now().strftime("%H:%M:%S"),"%H:%M:%S")
                x = datetime.datetime.strptime(df['Time'][item].strftime("%H:%M:%S"),"%H:%M:%S")
                if x==now:
                    print(True)
                    print(df['Heading'][item], df['Message'][item],df["Icon"][item])
                    if df["Icon"][item]=="nan":
                        df["Icon"][item]=""
                    if df["Message"][item]=="nan":
                        df["Message"][item]=""
                    if df["Heading"][item]=="nan":
                        df["Heading"][item]=""
                    notifyMe(df['Heading'][item], df['Message'][item],df['Icon'][item])
                    time.sleep(1)
                if  now<=x:
                    flag = False
            if flag:
                exit()
    

    Format of the xslx file

    你可以试试这个。可能对你有帮助

    【讨论】:

      猜你喜欢
      • 2020-04-26
      • 2021-07-16
      • 1970-01-01
      • 2021-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多