Python-Core-50-Courses icon indicating copy to clipboard operation
Python-Core-50-Courses copied to clipboard

第020课:函数使用进阶 高阶函数的用法 *args的位置有误

Open ghost opened this issue 4 years ago • 1 comments

存在问题:def calc(*, init_value, op, *args, **kwargs): 这条def语句明显是错误的,上文提及*是一个分隔符,*前面的都是位置参数,而*后面的是是关键字参数,*args就是接收任意多个位置参数。 解决方案:改为def calc(*args, init_value, op, **kwargs):,或者有其他更好的解决方案。

ghost avatar May 08 '20 00:05 ghost

存在问题 def calc(*args, **kwargs): result = 0 for arg in args: result += arg for value in kwargs.values(): result += value return total

其中 total 未曾被定义

daohuo-io avatar Sep 15 '20 03:09 daohuo-io