LoginSignup
0
0

More than 5 years have passed since last update.

【個人的備忘録】pythonのクロージャー

Posted at
◎クロージャー
def b(a, b):     #aとbを引数に指定 
    def inner():
        return a + b
    return inner    #innerを返さずに処理

p = b(100, 50)    #pにbの関数を代入
k = p()           #さらにそれをkに代入
print(k)          #最後にkを出力(innerがここで返されて処理される)
0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0