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)
  • 相关阅读:
    总结html5
    css加载方式link和@import的区别!
    JavaScript
    log4j log for java
    异常
    内部类
    抽象类和接口,封装、继承、多态
    类和对象
    html 基础知识
    html表单
  • 原文地址:https://www.cnblogs.com/wfl9310/p/8964180.html
Copyright © 2011-2022 走看看