「Python」関数内で関数を呼び出すサンプル

2021年7月16日

書式
def 関数A():
def関数B():
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#関数の定義
def testfunc():
x = 345
#内部関数
def testinnerfunc():
print("value is: ")
print(x)
testinnerfunc()
testfunc()
#関数の定義 def testfunc(): x = 345 #内部関数 def testinnerfunc(): print("value is: ") print(x) testinnerfunc() testfunc()
#関数の定義
def testfunc():
  x = 345
  #内部関数
  def testinnerfunc():
    print("value is: ")
    print(x)
  testinnerfunc()
testfunc()

実行結果
value is:
345

Python

Posted by arkgame