1. String Conversion
S. lower () to lowercase
S. upper () is converted to uppercase
S. swapcase () in upper case and lower case in upper case
S. capitalize () is capitalized.
Convert to int type string. atoi (s) or int (s)
Convert to float type string. atof (s) or float (s)
Convert to long type string. atol (s) or long (s)
2. Search and other operations
S. find (sub, [, start [, end]) returns the position where the first appearance occurs. If no position is found,-1 is returned.
S. rfind (sub, [, start [, end]) returns the position of the last occurrence. If no result is found,-1 is returned.
S. index (sub [, start [, end]) is similar to find (). If no value is found, ValueEerror is returned.
S. rindex (sub [, start [, end]) is similar to rfind (). If no value is found, ValueError is returned.
S. count (sub [, start [, end]) returns the number of times that a substring appears.
S. replace (old, new [, maxreplace]) replaces the string. When maxreplace is specified, only the first maxreplace is replaced.
S. strip (char) deletes the char at the beginning and end
S. split ([, seq [, maxsplit]) returns the list of split strings.
S. join ([sep]) connection string
3. Location
S. ljust (width [, fillchar]) left alignment
S. Align ust (width [, fillchar]) right alignment
S. center (width [, fillchar]) center
S. zfill (width) left fill zero until length to width
4. format the output
Format can change the output format of a string, for example:
'{0}, {2}, {1}'. format ('A', 'B', 'C ')
Here {0} {1} {2} respectively refer to 'a 'B'
You can also write it by name:
'Cordix: {x}, {y} '. format (x = '1', y = '2 ')
You can also use format to align the left of a string.
'{: <10}'. format ("hello") is left aligned and the width is 10.
'{:> 10}'. format ("hello") right alignment, width: 10
'{: ^ 10}'. format ("hello") center, width: 10