This article mainly introduces a concise summary of Python string processing functions. This article summarizes some common string processing functions. For more information, see
Returns the string with the specified characters removed.
Blank characters are removed by default.
Delete the first and last characters: str. strip ([char])
Delete the first character: str. lstrip ([char])
Delete str. strip ([char])
Determine whether to match the first and last characters
True is returned if the matching is successful. otherwise, False is returned.
Match the first character: str. startswith (char [, start [, end])
Match the last character: str. endswith (char [, start [, end])
Search for characters and find the position of the returned characters; otherwise,-1 is returned.
Search for str. find (char [, start [, end]) starting with a string.
Search for str. find (char [, start [, end]) from the end of the string.
Break down characters
Str. split ([sep [, maxsplit])
Connection character
Str. join (iterable)
"Str" is the connection character, and "iterable" is the connected iteratable string
Replacement Character
Str. replace (old, new [, count])
Returns the replaced string, which is the number of times the count mark is replaced. by default, all characters are replaced.
Breaks down strings by line breaks and returns the row list
Str. splitlines ([keepends])
Line breaks are not retained unless keepends is True.
Case-sensitive conversion
Case-insensitive: str. swapace ()
Convert to uppercase: str. upper ()
To lowercase: str. lower ()