Ganso into a string

Source: Internet
Author: User

Ganso into a string in this way:

Replacing a partial string in a string

 from string  = Template ('hello,${name}How was You,this is ${point},welcome to you'  ' Tom ' ' Beijing ' ) Print D output: Hello,tom How was You,this is Beijing,welcome
indexes and values for #enumberate可以找到字符串, list, Ganso
f ='HelloWorld' forI,tinchenumerate (f):if(i = =3): print t output: Index 3 corresponds to the value: La= ['AA','BB','cc','DD'] forI,tinchEnumerate (a):if(T = ='BB'): Print'the index of BB is:', i output: BB index is: 1c= ('ee','FF','GG','hh') forI,tinchEnumerate (c):if('GG'==t): Print'the index of GG is:', I
Output: The index of GG is: 2

Zip (ARG0,ARG1)

' Hellotom ','World'print zip (s,t)
Output: [(' H ', ' W '), (' E ', ' O '), (' L ', ' R '), (' l ', ' l '), (' O ', ' d ')]

= [' aaa ',' BBB ',' CCC ',' DDD ']
= [' GGG ',' hhh ',' III ',' KKK ',' JJJ ']
Zip (sss,ppp)
Output: [(' AAA ', ' GGG '), (' BBB ', ' HHH '), (' CCC ', ' III '), (' ddd ', ' KKK ')]
= (' TT ',' yy ',' uu ',' II ')
= (' One ', ' a ', ' + ', ' + ', ' + ',' 66 ')
Zip (PP,ss)
Output: [(' One ', ' TT '), (' + ', ' yy '), (' + ', ' UU '), (' + ', ' II ')]

It only matches the corresponding, paired output, and the rest does not output

Returns a fixed format that returns a list of tuples , which is a determined format.

arrays, strings, and meta-fathers they can be used with each other in zip ():

S4 = ('ACV','BDV','Eger') P4= ['AG','SFD','ASF','SF']print Zip (s4,p4) output: [('ACV','AG'), ('BDV','SFD'), ('Eger','ASF')]s5='HelloWorld'P5= ['AA','BB','ee','FF']print Zip (s5,p5) output: [('h','AA'), ('e','BB'), ('L','ee'), ('L','FF')]S6='Perfectone'P6= ('Eee','yyy','UUU','www','lll') Print zip (s6,p6) output: [('P','Eee'), ('e','yyy'), ('R','UUU'), ('F','www'), ('e','lll')]

Determine the type of variable: isinstance (' abc ', STR)

Print isinstance ('abc', str) output: Trueprint type ('ABC')  ) Output:string in'str'python is str

Ganso into a string

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.