您的位置:首页 > 编程语言 > Python开发

Python基础11--匿名函数和偏函数

2015-03-13 16:32 218 查看

Python基础11 匿名函数和偏函数

匿名函数

作为变量

map(lambda x: x * x, [1, 2, 3, 4, 5, 6, 7, 8, 9])


赋值

myabs = lambda x: -x if x < 0 else x


偏函数

自定义

def int2(x, base=2):
return int(x, base)


调用functools.partial定义

int2 = functools.partial(int, base=2)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python 匿名函数