Computer operating python two test sites are summarized title second track

a second channel operating python question is a relatively simple questions, and the first question is investigated as the knowledge of the string

  The main processing method will examine the string, the string sections or the like

Treatment often test string

 str.lower () : Returns a string copy all lowercase characters

upper (): On the contrary, all uppercase characters

str.split ( ""): constitute a partial list of character segmentation in parentheses ( !!! very important method, must be used)

str.replace (old, new): Returns a copy of the string, the string in the old sub-string of new replacement string sub

Detailed sections of the string

NOTE: string index is zero

Use slices: <string or string variable> [n: m]

Get String substring sections from n to m (not included m) of

Requirements slice n and m are both in the index section of the string, if m <= n null string is returned

Reverse same time decreasing number starting at -1

 

 Reverse output will learn little knowledge

Print (s :: [--1]) represents an output reverse output string s

 

 

Calculating the string length len (str)

print () function when the default text output a newline added at the end, if you do not wrap, can print) end function parameter assignment (using the following method

print (<output content to be>, end = "") ps: add a space after the outputting content

 

 

 

Published 11 original articles · won praise 1 · views 1321

Guess you like

Origin blog.csdn.net/lmd666/article/details/104554469