版权声明:转载请注明出处 https://blog.csdn.net/qq_42292831/article/details/89442155
>>>
>>> def A(data):
... def A_a():
... print(data)
... return A_a
...
>>> new = A(12)
>>> new
<function A.<locals>.A_a at 0x000000BEC82B0730>
>>> new()
12
>>> del A
>>> A(12)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'A' is not defined
>>> new()
12
>>> new
<function A.<locals>.A_a at 0x000000BEC82B0730>
>>>