#閉包似優化了變量,原來需要類對象完成的工作,閉包也可以完成
#由于閉包引用了外部函數的局部變量,則外部函數的局部變量沒有及時釋放,消耗內存
#示例一
# def user():
#? ? print("this is boy")
#? ? def users():
#? ? ? ? print("this is good boy")
#
#? ? return user
#
# res = user()
# print(res)
#示例二
def num(a,b):
? ? ?def number(x):
? ? ? returna*x + b
return ?number
res = num(1,2)
print(res)