![](/img/trans.png)
[英]I don't know why I keep getting AttributeError: 'tuple' object has no attribute 'size'
[英]I don't know why I keep getting the error 'str' has not attribute 'message'
from plyer import notifications
class Reminder():
def __init__(self,message = None):
if not message:
message = input("Please enter the message: ")
self.message = message
print(self.message)
def sendNotification(self):
print(self.message)
notification.notify(title = "Python reminder", message = self.message, app_name = "Python reminder program",app_icon = "",timeout = 10,ticker = "this is ticker thing")
def getTime(self):
pass
Reminder.sendNotification("message")
我得到的錯誤如下:
回溯(最近一次通話最后):文件“c:/Users/yomamahahaha/Desktop/oooohackrrr/actualprograms/python/Reminders/reminder.py”,第 28 行,在 Reminder.sendNotification("kek") 文件“c:/用戶/yomamahahaha/Desktop/oooohackrrr/actual programs/python/Reminders/reminder.py",第 20 行,在 sendNotification print(self.message) AttributeError: 'str' object has no attribute 'message'
您不創建 Reminder 的實例
所以當你打電話時
Reminder.sendNotification("message")
您在這里將 'self' 設置為 "message":然后調用"message".message
,它不存在
def sendNotification(self):
print(self.message)
我想你的意思是
myReminder = Reminder("Message")
myReminder.sendNotification()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.