Python返回内两层函数
def f():
print('call f()...')
# 定义函数g:
def g():
print('call g()...')
# 定义函数h:
def h():
print('call h()...')
# 返回函数h:
return h
# 返回函数g:
return g
x = f()
print(x)
y = x()
print(y)
z = y()
print(z)
>>> <function f.<locals>.g at 0x0000020E584749A0>
>>> call g()...
>>> <function f.<locals>.g.<locals>.h at 0x0000020E58474F40>
>>> call h()...
>>> None
为什么z作为返回函数h的对象,却没有地址呢?