希望大神解答,十分感谢!
def average(*args): sum = 0.0 if len(args) == 0: return sum for x in args: sum = sum + x return sum / len(args) print average() print average(1, 2) print average(1, 2, 2, 3, 4)
#请问为什么这里面的x遍历出来后直接是args值的和呢?
如果args为(1,2,3,4),遍历出来也应该是1,2,3,4啊?