下面的代碼是python的閉包
def line(a,b):
def sub_line(x):
return a*x+b
return sub_line
f = line(3,2) #此時f=3x+2
print (f(3)) #f(3) = 11
運行結果
C:\python3.8.1\python.exe D:/python/day3/demo.py
11
下面的代碼是python的閉包
def line(a,b):
def sub_line(x):
return a*x+b
return sub_line
f = line(3,2) #此時f=3x+2
print (f(3)) #f(3) = 11
運行結果
C:\python3.8.1\python.exe D:/python/day3/demo.py
11
繼續運行 🥋 回憶上次內容 上上次 真寫了 萬行 代碼 這 萬行 代碼 都是寫在 明面 上的 這次 使用git命令 下載了 github上面的倉庫