def add(x,y):
a = x + y
def average():
list1 = []
list1.append(a/2)
print(list1)
return a #为什么return a 放在这里呢,因为如果放在外面的话,根据return的属性,会结束嵌套数函数
return average() #为什么返回函数调用呢,是因为如果不返回函数调用的话,reduce()接受的函数就是函数的内存地址,先调用range在将add的作用加到reduce上
print(reduce(add,range(5)))
转载于:https://www.cnblogs.com/classmethond/p/8504435.html