已采纳回答 / fengniy
del 改成defdef add_flower(house_func): def rose(): return house_func()+" beautiful rose" return rose@add_flowerdef house(): return "A big house"print(house())
2016-07-01
#闭包学习
def my_sum(*arg):
print ('in my_sum')
return sum(arg)
def my_average(*arg):
return sum(arg)/len(arg)
def dec(func):
def in_dec(*arg):
print ('in dec arg=', arg);
if len(arg) == 0:
return o
for val in arg:
if not sinstance(val, int):
return 0
return func(*arg)
def my_sum(*arg):
print ('in my_sum')
return sum(arg)
def my_average(*arg):
return sum(arg)/len(arg)
def dec(func):
def in_dec(*arg):
print ('in dec arg=', arg);
if len(arg) == 0:
return o
for val in arg:
if not sinstance(val, int):
return 0
return func(*arg)
2016-06-28