from datetime import datetime
class sms_store:
store = []
read = []
def add_new_arrival(self,number,time,text):
sms_store.read.append(len(sms_store.store))
sms_store.store.append(("From: {}, Recieved: {}, Msg: {}".format(number,time,text)))
def delete(self,i):
try:
del sms_store.store[i]
except IndexError:
print("Index is out of range. Cannot delete")
def message_count(self):
return print("Amt of messages in inbox: {}".format(len(sms_store.store)))
def viewall(self):
print(sms_store.store)
def get_unread_indexes(self):
#### ###################################I need help for this method.
def get_message(self,i)
print(sms_store.store[i])
### tests ####
time = datetime.now().strftime('%H:%M:%S')
my_inbox = sms_store() #instantiate an object 'store' for class
my_inbox.add_new_arrival("12345",time,"Hello how are you?") #instance of store object
my_inbox.add_new_arrival("1111111",time,"BYE BYE BYE")
my_inbox.viewall()
my_inbox.msgcount()
感谢您查看此内容。
这是我需要做的:
my_inbox.add_new_arrival()
添加新消息时,其 has_been_viewed 状态设置为 False。
my_inbox.get_unread_indexes()
返回所有尚未查看的 SMS 消息的索引列表
my_inbox.get_message(i)**
返回 (from_number, time_arrived, text_of_sms) for message[i] 还将其状态更改为“已查看”。如果位置 i 没有消息,则返回 None
请帮助我了解上述方法!?
非常感谢!