def MainCount(f):
def progFirst(*args,**kwargs):
progFirst.calls+=1
return f(*args,**kwargs)
progFirst.calls=0
return progFirst
@MainCount
def progSecond(i):
return i+1
@MainCount
def Count(i=0,j=1):
return i*j+1
print(progSecond.calls)
for n in range(5):
progSecond(n)
Count(j=0,i=1)
print(Count.calls)
输出:0 一,
根据我的理解,MainCount(probsond),但我不明白probsond.calls如何等于零,同样在Count.calls中也是如此
正如您在MainCount函数probFirst.Calls中所看到的,当MainCount(probSecond)现在时,probSecond.Calls也是MainCount函数的属性
相关问题 更多 >
编程相关推荐