1. 程式人生 > >【Python】filter()的結果仍可以被filter()

【Python】filter()的結果仍可以被filter()

class root python3.6 hal 閱讀 lam question bin pre

def test_twice_filter(): list_a = [1, 2, 3, 4, 5] x = filter(lambda m: m > 2, list_a) y = filter(lambda n: n < 4, x) print(list(y)) if __name__ == ‘__main__‘: test_twice_filter()

結果:

ssh://[email protected]:250/usr/bin/python3.6 -u /home/dba/HAL_9000/dbAlertAPP/filters/misc_item_filter.py
[3]

參考閱讀:

  • Listing a filter object twice will return a blank list?

【Python】filter()的結果仍可以被filter()