1 stus = ['zhansan','lisi','wangwu','xiaohei'] 2 def add_pre(name): 3 return 'cnz_%s' % name 4 5 result = list(map(add_pre,stus)) 6 print(result) 7 # map作用 8 # map循环调用函数 9 # map每次循环的返回值保存,最后返回 10 11 12 # filter作用 13 # filter循环调用函数 14 # filter过滤传入的参数,如果为true,就保存,为false,就丢弃 15 stu_score = [60,30,90,25,100,85] 16 result1 = list(filter(lambda score:score>=60,stu_score)) 17 print(result1)