2017年5月15日

filter

摘要: 看到一个比较有趣的程序 def not_empty(s): return s and s.strip() print(list(filter(not_empty, ['A', '', 'B', 'C ',None, ' ']))) 结果是['A', 'B', 'C '] 这里的函数我本来自己写成如下 阅读全文

posted @ 2017-05-15 23:21 vonkimi 阅读(101) 评论(0) 推荐(0) 编辑

函数式编程

摘要: 1、变量可以指向函数 2、函数名即为变量 3、函数可以作为另外一个函数的传入参数,这样另一个函数即为高阶函数 4、map函数 map()函数接受两种参数,map(f,Iterable),其中f为函数变量,Iterable为可迭代的对象,如list或者tuple或者dict等 map()函数的作用是把 阅读全文

posted @ 2017-05-15 22:42 vonkimi 阅读(96) 评论(0) 推荐(0) 编辑

导航