首页 > 代码库 > python之参数解包

python之参数解包

# 参数解包:将整个list当做参数传给函数
list = [1, 2, 4]


def add_fn(a, b, c):
    return a + b + c


sum = add_fn(*list)
print("参数解包:", sum)

 运行结果:

参数解包: 7

 

python之参数解包