filter(function, an_iter)
*If the iterable an_iter is a sequence, then the returned value is of that same type,
otherwise the returned value is a list.*
我在Python中的filter(func, a_sequence)
函数定义中看到了上面的描述。
我理解filter
如何在序列类型(列表、字符串、元组)上工作,但你能否给出一些an_iter
参数是非序列类型的情况以及生成什么样的结果呢?
xrange()
,生成器等。 - Ashwini Chaudhary