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