摘要: 1、编写无参数的decoratorPython的 decorator 本质上就是一个高阶函数,它接收一个函数作为参数,然后,返回一个新函数。使用 decorator 用Python提供的 @ 语法,这样可以避免手动编写 f = decorate(f) 这样的代码。def log(f): def fn(x): print 'call ' + f.__name__ + '().... 阅读全文
posted @ 2015-12-15 16:37 指上弹兵赵小括 阅读(277) 评论(0) 推荐(0) 编辑
摘要: 慕课网 http://www.imooc.com/1、变量可以指向一个函数(函数名相当于一个变量)12345import mathdef add(x, y, fun): return fun(x) + fun(y) print(add(25, 9, math.sqrt))2、map函数【python 2】Help on built-in function map in module __bu... 阅读全文
posted @ 2015-12-15 15:35 指上弹兵赵小括 阅读(196) 评论(0) 推荐(0) 编辑