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

    nums=[11,34234,23,344,123,1,23,124,523,4,12342341,423,43545]
    
    nums.sort()
    
    print(nums)
     
    #这个就是排序,从小到到

    匿名函数:

     1 def test(a,b,func):
     2 result=func(a,b)
     3 return result
     4 
     5 num=test(11,22,Lambda x,y:x+y)
     6 print(num)
     7 
     8 #匿名函数当做参数
     9 
    10 #1.首先把11 22的值传给a b ,然后把Lambda x,y:x+y的值传给func,
    11 #2.然后下面func里面的参数又是a b,此时的func也就是匿名函数 Lambda x,y:x+y 
    12 # 也就是 把a传给x,把b传给y  
    13 # 3.然后接下来就是return       比较晕,多做做就好了 
    14 
    15 #Lambda x,y:x+y 就是匿名函数
  • 相关阅读:
    【Python爬虫】:模拟登录QQ空间
    Docker
    Git
    DevOps
    DevOps
    gRPC 简介
    tcpdump的使用
    Raft
    go-micro 简介
    Node
  • 原文地址:https://www.cnblogs.com/suiyisuixing/p/7625430.html
Copyright © 2011-2022 走看看