zoukankan      html  css  js  c++  java
  • 高阶函数

    #高阶函数
    # def f(n): #函数名是一个变量 函数是一个对象
    # return n*5
    # def ff(a,b,fun):
    # print(fun(a)+fun(b))
    # ff(1,2,f)


    #函数名可以赋值
    def f():
    print("ok")
    return 1
    foo = f #赋值后两个函数名都指向同一个地址值
    c = foo() #接收return 1的返回值
    print("函数值:",c)

    #函数名可以作为函数的参数
    def g(a,b,ab):
    ab() #执行ab对象的函数
    return 2
    re = g(1,2,foo) #把函数的foo对象作为参数
    print(re) #return 2 的返回值

    #函数名可以作函数返回值
    def js():
    print("我是第一层")
    def js2():
    return 9
    return js2 #把函数js2()的对象js2返回给js()函数
    cjs = js()
    print(cjs())
  • 相关阅读:
    重装Win10系统的非常简单的操作教程
    Python
    Delphi
    Libs
    Windows Server
    Windows Server
    Delphi
    Delphi
    Delphi
    Delphi
  • 原文地址:https://www.cnblogs.com/TKOPython/p/11668385.html
Copyright © 2011-2022 走看看