Note that a character array is passed in, and the compiler strips out all the corresponding characters at both ends until there are no matching characters, such as:
Copy the Code code as follows:
TheString = ' Saaaay Yes No yaaaass '
Print Thestring.strip (' say ')
TheString is removed sequentially from the characters in the [' s ', ' a ', ' Y '] array until the character is within the array. Therefore, the result of the output is:
Yes No
Quite simply, Lstrip and Rstrip are the same principle. Note: When there are no incoming parameters, the default is to remove the leading and trailing spaces.
Copy the Code code as follows:
TheString = ' Saaaay Yes No yaaaass '
Print Thestring.strip (' say ')
Print Thestring.strip (' say ') #say后面有空格
Print Thestring.lstrip (' say ')
Print Thestring.rstrip (' say ')
Operation Result:
Yes No
Es No
Yes No Yaaaass
Saaaay Yes No