标签:
def first(f):
print f.__name__,‘call first()‘
def fn_1():
print f.__name__,‘call first()_ fn_1()‘
return f()
return fn_1
def second(f):
print f.__name__,‘call second()‘
def fn_2():
print f.__name__,‘call second()_fn_2()‘
return f()
return fn_2
def test():
print ‘test‘
test = first(second(test))
test()
def first(f):
print f.__name__,‘call first()‘
def fn_1():
print f.__name__,‘call first()_ fn_1()‘
return f()
return fn_1
def second(f):
print f.__name__,‘call second()‘
def fn_2():
print f.__name__,‘call second()_fn_2()‘
return f()
return fn_2
@first
@second
def test():
print ‘test‘
test()
第一种是对第二种的解释
运行结果
为什么 fn_2 call first_fn_1()与 test call second_fn_2()都会运行呢?
此时的fn_2 与test分别是传入first和second的变量f的名字
标签:
原文地址:http://www.cnblogs.com/ylw666/p/5689606.html