小编rgo*_*kar的帖子

在Python中解释关键字参数(VarArgs)

请参阅以下代码: -

#!/usr/bin/python
# Filename: total.py

def total(initial=5, *numbers, **keywords):
    count = initial
    for number in numbers:
        count += number
    for key in keywords:
        count += keywords[key]
    return count

print(total(10, 1, 2, 3, vegetables=50, fruits=100))
Run Code Online (Sandbox Code Playgroud)

有人可以解释一下*数字和**关键字如何获取参数?很简单的解释非常感谢提前感谢

python variadic-functions

17
推荐指数
1
解决办法
1万
查看次数

标签 统计

python ×1

variadic-functions ×1