我使用的是Python 3,我的问题是为什么输出不同?
print([x * x for x in range(2, 5, 2) if x % 4 == 0]) # returns [16] q = [x * x for x in range(2, 5, 2)] print(list(filter(lambda x: x % 4 == 0, q))) # returns [4, 16]
python list-comprehension list filter
filter ×1
list ×1
list-comprehension ×1
python ×1