Python full stack development--function type

Source: Internet
Author: User

#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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.