Ad
1: 2016-07-24 (日) 05:57:00 njf ソース バックアップ No.1 を復元して編集 2: 2016-07-24 (日) 06:05:06 njf ソース バックアップ No.2 を復元して編集
Line 4: Line 4:
     print "test!"      print "test!"
 +実行
 testFunction()  testFunction()
Line 9: Line 10:
 test!  test!
 +
 +引数や戻り値ももちろん定義できる。
 +
 + def test2Function(str):
 +     return str
 +実行
 + print test2Function("test2!")
 +
 +結果
 +
 + test2!
 +
 +引数のデフォルト値も定義できる。
 +
 + def test3Function(a=1,b=2,c=3):
 +   print "%d %d %d" % (a, b, c)
 +
 + >>> test3Function()
 + 1 2 3
 + >>> test3Function(2)
 + 2 2 3
 + >>> test3Function(2,3)
 + 2 3 3
 + >>> test3Function(2,3,4)
 + 2 3 4
 +
 +また、特定の引数のみを明示して実行もできる。
 + >>> test3Function(b=2)
 + 1 2 3
 +
 +関数を変数にする事も可能。
 +
 + >>> t = test3Function
 + >>> t()
 + 1 2 3


トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード印刷に適した表示   ページ新規作成 全ページ一覧 単語検索 最新ページの一覧   ヘルプ   最新ページのRSS 1.0 最新ページのRSS 2.0 最新ページのRSS Atom Powered by xpWiki
Counter: 1655, today: 1, yesterday: 0
MenuBar
広告

ログイン

ユーザー名:


パスワード:





パスワード紛失

Portuguese | English | German | Greek | Japanese | Korean | Russian | T-Chinese top
NJF