python 偏函数

from functools import partial


def test(x, y):
    return x + y


# 1.普通函数调用
ret = test(1, 2)
print(ret)      # 3

# 2.偏函数调用
new_test = partial(test, 10)
ret = new_test(2)
print(ret)      # 12

 过程:导入模块->创建新的函数

posted @ 2019-09-28 22:19  市丸银  阅读(144)  评论(0编辑  收藏  举报