June 24 day1 paython based learning Homework

name= " aleX"
print(name)
print (name.strip ()) # removed name spaces on both sides of the value corresponding to the variable, and outputs the processing result
print (name.startswith ( 'al')) # determines whether or not the value corresponding to the variable name beginning with "al", and outputs the result

print (name.endswith ( 'X')) # corresponding to the variable name is determined whether the value of an "X" at the end, and outputs the result

name2=name.replace('l','p')
print (name2) # value corresponding to the variable name in the "l" is replaced with "p", and outputs the result
print (name.split ( 'l')) # variable name corresponding to the value in accordance with "l" division, and outputs the result.
print (name.upper ()) # The name becomes a variable value corresponding to upper case, and outputs the result

print (name.lower ()) # The name corresponding to the variable value becomes lower case, and the output

print (name [2]) # Please variable name corresponding to an output value of the second character
The first three characters of a value corresponding to the variable name, please output #: print (name [4 0])
print (name [-2 ::]) # Please outputs two values ​​corresponding to the variable name character?

print (name.find ( 'e')) # request an output value corresponding to the variable name index where "e" position?

# Or print (name.index ( 'e'))
print (name.strip ( 'X')) # acquisition sequence, the last character is removed. Such as: oldboy then get oldbo.

 Compile the results:

 

Guess you like

Origin www.cnblogs.com/zhylouqi/p/11079300.html