#map (a method (typically a lambda expression, or a custom method) that iterates over an object (which can be traversed with a for loop).
#处理序列中的每个元素, the result is a list with the same number of elements and position as the original
num=[1,2,34,223,1,3 " def C (d): return d**2def text (list,h): Tet =[] for e in list:res =< Span style= "COLOR: #000000" >h (e) tet.append (res) return tet print (text (Num,lambda x:x**2 print (List ( Map (lambda x:x+1,num))) Print (List (map (c,num)))
#filter (a method (typically a lambda expression or a custom method) that iterates over an object (which can be traversed with a for loop).
#遍路序列中的每个元素, judge each element to get a Boolean value, if ture, keep it down
move_people=['SBZ_DGDRH','Sb_jh','Sb_jty','Sbfs','HJF','HFJ','DFJSB']deffiler (people,string): Ret=[] forEinchmove_people:b=e.find (String)ifB==-1: Ret.append (E)returnretPrint(Filer (Move_people,'_'))Print (list (filter (lambda n:not n.startswith (' SB '), Move_people )))
#reduce
#from functools Import Reduce
fromFunctoolsImportReducesum1=0defJia (a):Globalsum1 sum1+=areturnsum1deftext (arrary,fun): s=0 forEincharrary:s+=Fun (e)returnSnum=[1,2,4,5,4,6,8,7,6,4,12]Print(Text (Num,jia))print (Reduce (lambda x,y:x+y,num))
Python full stack development--function type