zoukankan      html  css  js  c++  java
  • 匿名函数

    list = [{"name":"hello","age":12},{"name":"world","age":5},{"name":"today","age":23}]
    list.sort(key=lambda x:x["age"])
    print(list)

    匿名函数当做实参

    def test(a,b,func):
        result = func(a,b)
        return result
    
    num = test(11,22,lambda x,y:x+y)
    print(num)

    匿名函数的应用

    def test(a,b,func):
        result = func(a,b)
        return result
    
    func_new = input("请输入一个匿名函数:")
    func_new = eval(func_new)
    num = test(11,22,func_new)
    print(num)
  • 相关阅读:
    053-242
    053-227
    053-671
    053-489
    053-670
    sql
    白纸黑字签字画押,出人命的事
    CSS
    JS
    Eclipse发布地址不同引发的问题
  • 原文地址:https://www.cnblogs.com/rongpeng/p/12495173.html
Copyright © 2011-2022 走看看