The strip in Python is used to remove the first (left) character of a string, and Lstrip is used to remove the left character, Rstrip to remove the right character. All three functions can pass in one parameter, specifying the first and last characters to be removed.
s= ' Saaaay Yes no Yaaaas '
print s.strip (' say ') #结果是 ' Yes no '
Explanation: The incoming is an array of characters, the compiler removes all the corresponding characters at both ends until there are no matching characters. The array of characters passed in is [' s ', ' a ', ' Y '], from the sides of the string s, if any character in the character array is encountered (in character order), the character is deleted, otherwise the operation stops.
If the strip () does not pass the parameter, the default deletion of whitespace characters (including ' \ n ', ' \ R ', ' \ t ', ')
Several instances are given below
>>> s= ' saaay yes no Yaaaas '
>>> s.strip (' say ')
' saaay Yes No Yaaaas '
>>> s= ' ay uyes no '
>>> s.strip (' say ')
' Uyes no '