filter函数的第一个输入是一个返回值为boolean的函数名,第二个是一个可迭代类型,返回值和map函数一样,是个迭代器
telma = ["Chris", "John","Jack","Tom"] res = filter(lambda x:x.startswith("J"),telma) print(list(res))
[‘John‘, ‘Jack‘]
filter函数
原文:https://www.cnblogs.com/telma/p/10505346.html