Python 表达式模块错误';过滤对象';

Python 表达式模块错误';过滤对象';,python,regex,Python,Regex,我正在学习表达模块,也在这个网站上 我在9.1中做了第一个练习 s = ['airplane', 'base', 'ALLIGATOR', 'Broad' ] filter((lambda x: re.match(r'A', x)),s) 答案是['ALLIGATOR'] 但我明白了 <filter object at 0x102c36550> 作为我的答案,我不是['ALLIGATOR'] 我正在使用Python 3.4.2 你知道怎么了吗 引用 从iterable的

我正在学习表达模块,也在这个网站上

我在9.1中做了第一个练习

s = ['airplane', 'base', 'ALLIGATOR', 'Broad' ]

filter((lambda x: re.match(r'A', x)),s)
答案是
['ALLIGATOR']

但我明白了

<filter object at 0x102c36550> 

作为我的答案,我不是
['ALLIGATOR']

我正在使用Python 3.4.2 你知道怎么了吗

引用

从iterable的那些元素构造一个迭代器,函数为其返回true。iterable可以是序列、支持迭代的容器或迭代器。如果function为None,则假定identity函数,即删除iterable中所有为false的元素

请注意,如果函数不是None,则filter(function,iterable)等价于生成器表达式
(iterable if function(item))
(iterable if item中的item)和
(iterable if item中的item)
(如果函数是None)

要获取这些元素,您需要一个循环或使用
next

>>> next(filter(lambda x: re.match(r'A', x), s))
'ALLIGATOR'

我的答案是
 >>> [word for word in filter(lambda x: re.match(r'A', x), s)]
 ['ALLIGATOR']