在python中使用列表中的布尔值调用字符串

在python中使用列表中的布尔值调用字符串,python,python-2.7,list,Python,Python 2.7,List,我有一个列表'SMSStore',其中包含一个[boolean,string1,string2]例如 [(False, 'roro', '07189202003'), (False, 'rtptp', '07189202003'), (True, 'rtptp', '07189202003')] 我想要一个函数,它将循环遍历列表,检查布尔值并返回所有假布尔值的string1 class SMSMessage(object): def __init__(self, hasBeenRea

我有一个列表
'SMSStore'
,其中包含一个
[boolean,string1,string2]
例如

[(False, 'roro', '07189202003'), (False, 'rtptp', '07189202003'), (True, 'rtptp', '07189202003')]
我想要一个函数,它将循环遍历列表,检查布尔值并返回所有假布尔值的string1

class SMSMessage(object):

    def __init__(self, hasBeenRead, messageText, fromNumber):
        self.hasBeenRead = hasBeenRead
        self.messageText = messageText
        self.fromNumber = fromNumber


hasBeenRead = False

**def get_unread_messages(hasBeenRead):
    for i in SMSStore[:][0]:
        if hasBeenRead == False:
             return messageText**
简单问题的简单列表理解:

...

def get_unread_messages(l):
    return [t[1] for t in l if not t[0]]


l = [(False, 'roro', '07189202003'), (False, 'rtptp', '07189202003'), (True, 'rtptp', '07189202003')]
print(get_unread_messages(l))
输出:

['roro', 'rtptp']