#coding:utf-8def my_sum(*arg): return sum(arg)def my_average(*arg): print('in my_sum') return sum(arg)/len(arg)def dec(func): def in_dec(*arg):#my_sum print('in dec arg=',arg) if len(arg) ==0: return 0 for val in arg: if not isinstance(val,int): return 0 return func(*arg) return in_dec#my_sum=dec(my_sum) #dec return in_dec ->my_summy_sum=dec(my_sum)my_average=dec(my_average)print(my_sum(1,2,3,4,5))print(my_sum(1,2,3,4,5,6))print(my_average(1,2,3,4,5))print(my_average)
添加回答
举报
0/150
提交
取消