zoukankan      html  css  js  c++  java
  • 函数式编程filter函数,list()表示列表显示值

    
    
    # movie_person=['alxe','tom','jerry','man']
    # def m_show(n):
    #     return n.endswith('m')
    # def filter_test(array):#array表示列表作为数据使用,打印不是m开头的
    #     ret=[]
    #     for p in movie_person:
    #         if not p.startswith('m'):#不是m开头的
    #             ret.append(p)#吧movie中不是m开头的追加到ret列表中
    #     return ret
    # res=filter_test(lambda n:n.endswith('m'), movie_person)#函数加对象列表执行
    # print(res)
    # filter函数
    movie_person=['alxe','tom','jerry','man']
    # print(filter(lambda n:n.endswith('m'),movie_person))
    print((filter(lambda n:not n.endswith('m'),movie_person)))
    res=filter(lambda n:not n.endswith('m'),movie_person)
    print(list(res))#list()列表显示
    
    
    


    #filter函数 movie_person
    =['alxe','tom','jerry','man'] def filter_test(array):#array表示列表作为数据使用,打印不是m开头的 ret=[] for p in movie_person: if not p.startswith('m'):#不是m开头的 ret.append(p)#吧movie中不是m开头的追加到ret列表中 return ret res=filter_test(movie_person)#函数加对象列表执行 print(res) movie_person=['alxe','tom','jerry','man'] def filter_test(array):#array表示列表作为数据使用,打印不是m开头的 ret=[] for p in movie_person: if not p.endswith('m'):#不是m结尾的 ret.append(p)#吧movie中不是m开头的追加到ret列表中 return ret res=filter_test(movie_person)#函数加对象列表执行 print(res)
  • 相关阅读:
    C# 泛型
    EventHandler<TEventArgs>委托
    只能输入数字 ,只能有一位小数点。
    MVC过滤器 AuthorizeAttribute使用
    NuGet EntityFramework 常用命令
    Stride游戏引擎试毒
    Unity EditorWindow GUI裁剪
    unity2017自定义编译dll
    Unity
    WPF
  • 原文地址:https://www.cnblogs.com/wfl9310/p/8964180.html
Copyright © 2011-2022 走看看