Closure是一个函数对象,它记住封闭范围中的值,即使它们不在内存中也是如此。
# Python program to illustrate
# closures
def outerFunction(text):
text = text
def innerFunction():
print(text)
return innerFunction # Note we are returning function WITHOUT parenthesis
if __name__ == '__main__':
myFunction = outerFunction('Hey!')
myFunction()
2. 函数innerFunction的范围仅在outerFunction内。但是通过使用闭包,我们可以轻松地扩展其范围以调用其范围之外的函数。
三个资料Q群下载不了也转发不了,先放这里Fine_tuning.zipLangChain.zipdata_clear.rar