lambda 匿名函数的使用
>>> a=lambda x : x in "1234567890.," >>> a("asd") False >>> a("123") True >>> filter(lambda x : x in "1234567890.,","123asd") '123'
加上filter的混合使用:
>>> filter(lambda x : x in "1234567890.,","123asd") '123'
filter后面的跟的参数是function和string(当然也可以是list)
>>> filter(lambda x : x in "1234567890.,",['1','2','3','a']) ['1', '2', '3']