Top.Mail.Ru
Ответы

Проблема с pycharm

написал код

import schedule

import time

from plyer import notification

def show_notification(message):

    notification.notify(

        title="Напоминание",

        message=message,

        timeout=10

    )

def add_reminder(text, reminder_time):

    schedule.every().day.at(reminder_time).do(show_notification, message=text)

    print(f"Напоминание добавлено на {reminder_time}: {text}")

if name == "main":

    while True:

        text = input("Введите текст напоминания: ")

        reminder_time = input("Введите время (формат ЧЧ:ММ): ")

        add_reminder(text, reminder_time)

        print("Ожидание напоминания...")

        while True:

schedule.run_pending()

            time.sleep(1)

Но он выдает ошибку

Traceback (most recent call last):

  File "C:\Users\zapal\PycharmProjects\pythonProject1\2.py", line 23, in <module>

    add_reminder(text, reminder_time)

    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^

  File "C:\Users\zapal\PycharmProjects\pythonProject1\2.py", line 15, in add_reminder

    schedule.every().day.at(reminder_time).do(show_notification, message=text)

    ^^^^^^^^^^^^^^^^^^^^

AttributeError: 'NoneType' object has no attribute 'day'

На визуал студио все работает

Но нужно именно на пайчарм