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)
  • 相关阅读:
    File初识和练习
    图床
    servlet
    css伪类及伪元素用法
    css中的定位position
    块级元素与行级元素
    清除浮动
    CSS浮动
    fastjson 1.2.6以下版本 解析字符串末尾出现/x会陷入死循环 报oom异常
    记一次select2赋值动态数组的坑
  • 原文地址:https://www.cnblogs.com/wfl9310/p/8964180.html
Copyright © 2011-2022 走看看