Function prototypes
Declaration: S is a string, RM is a sequence of characters to be deleted
S.strip (RM) Remove the characters from the beginning and end of the s string in the RM delete sequence
S.lstrip (RM) Delete the character in the S string at the beginning of the RM delete sequence
S.rstrip (RM) Removes the character from the end of the S string that is located in the RM delete sequence
Attention:
1. When RM is empty, the default is to remove the whitespace characters (including ' \ n ', ' \ R ', ' \ t ', ')
For example:
Copy the Code code as follows:
>>> a = ' 123 '
>>> A.strip ()
' 123 '
>>> a= ' \T\TABC '
' ABC '
>>> a = ' sdff\r\n '
>>> A.strip ()
' SDFF '
2. The RM delete sequence here is deleted as long as the character on the edge (beginning or end) is within the delete sequence.
For example:
Copy the Code code as follows:
>>> a = ' 123abc '
>>> A.strip (' 21 ')
' 3abc ' turns out to be the same
>>> A.strip (' 12 ')
' 3abc '
Python strip ()