为了能让一个函数接受任意数量的位置参数,可以使用一个*参数。例如:. def avg(first, *rest): return (first + sum(rest)) / (1 + len(rest)) # Sample use avg(1, ...
確定! 回上一頁