Map reduce usage str processing lower () capitalize ()

Source: Internet
Author: User

--

1s='123456'2l={'0'70A'1': 1,'2': 2,'3': 3,'4': 4,'5'75A'6': 6,'7': 7,'8': 8,'9': 9}[s[0]]3 Print(l)

Remove the key element from DIC

 1  def   Normalize (name):  2  tempn=name.lower (). Capitalize ()  3  return   TEMPN  4  L1 = ["  adam   ", "  Span style= "COLOR: #800000" >lisa   ",   bart   "  ]  5  L2 = list (map (normalize, L1))  Span style= "COLOR: #008080" >6  print  (L2) 

Capitalize the first letter only, and the rest of the lowercase one uses the string lower () capitalize () function

1 ##sum2num1=[20,30,50]3 Print(SUM (num1[1:]))4 ##multiply5 defprod (L):6     returnReduceLambdax,y:x*y, L)7l3=[1,2,3,4,6]8 Print(Prod (l3[:2]))9 Print(1*2)

List summation and quadrature functions where reduce lambda expressions are used

1 defStr2float (s):2Tempstr=s.split ('.')3Ustr=tempstr[0]+tempstr[1]4     defStr2Num (R):5         return{'0': 0,'1': 1,'2': 2,'3': 3,'4': 4,'5': 5,'6': 6,'7': 7,'8': 8,'9': 9}[r]6Ws=len (tempstr[1])7     returnReduceLambdaX, y:x * + y, map (Str2Num, USTR))/(10**WS)

--str convert the float function. The idea is to remove the decimal point, convert it to an integer, and divide by the number of decimal places.

Map reduce usage str processing lower () capitalize ()

Related Article

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.