2019_6_24_ jobs

name = " aleX"

# 1) is removed either side of a value corresponding to the variable name spaces, and outputs the processing result 
Print (name.strip ())

# 2) determines whether the value of the corresponding variable name begins with "al", and outputs the result Print (name.startswith ( ' Al ' ))

# Whether 3) determines the value of the variable name corresponds to "X" at the end, and outputs the result Print (name.endswith ( ' X- ' ))

# 4), the values corresponding to the variable name in the "l" is replaced with "p", and outputs the result 
Print (name.replace ( ' L ' , ' P ' ))

# 5) The name of the corresponding variable value in accordance with "l" division, and outputs the result. 
Print (name.split ( ' L ' ))

# 6) The name corresponding to the variable value becomes capital, and outputs the result Print (name.upper ())

# 7) The name corresponding to the variable value becomes lower case, and outputs the result Print (name.lower ())

# 8) outputs a second request character corresponding to the variable name values? 
Print (name [. 1 ])

# ? 9) Make the output value of the first three characters of the name variable corresponding 
Print (name [: 3 ])

# 10) Please outputs two values corresponding to the variable name character? Print (name [-2 :])

# 11) make an output value corresponding to the variable name index where "e" position? 
LOC = []
 for I, J in the enumerate (name):
     IF J == ' E ' :
        loc.append(i)
print (place)

# 12) to obtain sequences, removing the last character. Such as: oldboy then get oldbo. 
Print (name [: -. 1])

 

Guess you like

Origin www.cnblogs.com/yy-yang/p/11080115.html