「Python」def関数と無名関数lambdaを使うサンプル

2021年2月26日

書式
def 関数名(引数):
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
def testfunc(n):
return lambda x : x * n
res = testfunc(2)
print("計算テスト")
print(res(11))
def testfunc(n): return lambda x : x * n res = testfunc(2) print("計算テスト") print(res(11))
def testfunc(n):
  return lambda x : x * n

res = testfunc(2)

print("計算テスト")
print(res(11))

実行結果
計算テスト
22

Python

Posted by arkgame