Article reproduced in: Http://www.cnblogs.com/itdyb/p/5046472.html (Bo Master: Bobby 12)
This explains the strip () function in the Python API:
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:
>>> a= ' Hello World ' >>> a ' Hello World ' >>> a.strip () ' Hello World ' > >> x= ' \t\r\npython ' >>> x ' \t\r\npython ' >>> x.strip () ' Python '
The 2.rm delete sequence is deleted as long as the character on the edge (beginning or end) is within the delete sequence.
For example:
>>> astring= ' 123love ' >>> astring ' 123love ' >>> astring.strip (' + ') ' 3love '
Python built-in functions: strip ()