回覆列表
  • 1 # kilpu14974

    在計算機程式設計中,回撥函式,或簡稱回撥(Callback),是指透過函式引數傳遞到其它程式碼的,某一塊可執行程式碼的引用。這一設計允許了底層程式碼呼叫在高層定義的子程式:例如:執行結果是:

  • 2 # 範閒不是我

    在計算機程式設計中,回撥函式,或簡稱回撥(Callback),是指透過函式引數傳遞到其它程式碼的,某一塊可執行程式碼的引用。這一設計允許了底層程式碼呼叫在高層定義的子程式:

    例如:

    def my_callback(input): print "function my_callback was called with %s input" % (input,)def caller(input, func): func(input)for i in range(5): caller(i, my_callback)

    執行結果是:

    function my_callback was called with 0 inputfunction my_callback was called with 1 inputfunction my_callback was called with 2 inputfunction my_callback was called with 3 inputfunction my_callback was called with 4 input

  • 中秋節和大豐收的關聯?
  • 怎樣給雪納瑞美容?