Learning python first day of work

= name ' Alex ' 
# . 1) removed on both sides of the value corresponding to the variable name spaces, and outputs the processing result 
Print (name.strip ())
 # 2) determines whether the value corresponding to the variable name beginning with "al", and outputs the result Print (name.startswith ( ' Al ' ))
 # . 3) determines whether the value of the corresponding variable name ending in "X", and outputs the result Print (name.endswith ( ' X- ' ))
 # . 4) to a value corresponding to the variable name the "l" is replaced with "p", and outputs the result 
Print (name.replace ( ' L ' , ' P ' ))
 # . 5) the variable name corresponding to segmentation according to "l", and outputs the result. 
Print (name.split ( '' ))
 # 6) becomes a value corresponding to the variable name in uppercase, and outputs the result Print (name.upper ())
 # . 7) corresponding to the name of the variable value becomes lower case, and outputs the result Print (name.lower ())
 # 8) Please outputs the second character values name corresponding variable? 
Print (name [. 1 ])
 # . 9) Please outputs the first three characters values name corresponding variable? 
for Line in name [2 ]:
     Print (name [ 2 ])
 # after 10) make the output value corresponding to the variable name in two characters? Print (name [-2 :])
 # . 11) requested output value corresponding to the variable name index where "e" position? Print (name. index ( ' E ' ))
 #12) acquisition sequences, removing the last character. Such as: oldboy then get oldbo. 
Print (name [: -. 1])

 

Guess you like

Origin www.cnblogs.com/fb1704011013/p/11079158.html