How to find the length of a “filter” object in python
问题 >>> n = [1,2,3,4] >>> filter(lambda x:x>3,n) <filter object at 0x0000000002FDBBA8> >>> len(filter(lambda x:x>3,n)) Traceback (most recent call last): File "<pyshell#3>", line 1, in <module> len(filter(lambda x:x>3,n)) TypeError: object of type 'filter' has no len() I could not get the length of the list I got. So I tried saving it to a variable, like this... >>> l = filter(lambda x:x>3,n) >>> len(l) Traceback (most recent call last): File "<pyshell#5>", line 1, in <module> len(l) TypeError: