>>> def funX(x):
def funY(y):
return x * y
return funY
>>> i = funX(5)
>>> print(i)
<function funX.<locals>.funY at 0x00000211C3D16A60>
>>> type(i)
<class 'function'>
>>> i(5)
25
>>> funX(5)(6)
30
>>> def funX(x):
def funY(y):
return x * y
return funY
>>> i = funX(5)
>>> print(i)
<function funX.<locals>.funY at 0x00000211C3D16A60>
>>> type(i)
<class 'function'>
>>> i(5)
25
>>> funX(5)(6)
30
本文标题:闭包
本文链接:https://www.haomeiwen.com/subject/otaqlxtx.html
网友评论