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

Python里面的partial 函数

2013-08-22 10:30 302 查看
import functools

def add(a, b):
return a + b

addplus3 = functools.partial(add, 3)
result = addplus3(7)
# 10

addplus3and9 = functools.partial(add, 3, 9)
result = addplus3and9()
# 12

result = addplus3and9(0)
#TypeError: add() takes exactly 2 positional arguments (3 given)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: