这是一个基本问题。我正在尝试以下代码:
class SMS_store:
def __init__(self):
self=[] #probably something is wrong here
def add_new_arrival(self,from_number,time_arrived,text_of_SMS):
self.append([False,from_number,time_arrived,text_of_SMS]) #append list to self list
self[len(self)-1]=tuple(self[len(self)-1])
def message_count(self):
return len(self)
my_inbox=SMS_store()
my_inbox.add_new_arrival('01234','9:37 AM','How are you?')
但我收到以下错误:
>>>
Traceback (most recent call last):
File "C:\Users\Arnob\Desktop\New Text Document.py", line 15, in <module>
my_inbox.add_new_arrival('01234','9:37 AM','How are you?')
File "C:\Users\Arnob\Desktop\New Text Document.py", line 8, in add_new_arrival
self.append([False,from_number,time_arrived,text_of_SMS]) #append list to self list
AttributeError: 'SMS_store' object has no attribute 'append'
>>>
我的代码有什么问题?