函数
def text():
print(‘xxx’)
text()
def test(num1, num2=1):
print(num1 + num2)
test(2)
拆包、装包
def mySum(a, b, c):
print(a + b + c)
def test(*args):
print(*args)
mySum(*args)
test(4, 5, 8)
偏函数
偏函数需要给新函数赋值,代入数值时,是按照顺序进行
def test(a, b, c, d):
print(a + b + c + d)
import functools
newFun = functools.partial(test, d=5)
newFun(1, 2, 3)