Strip () function in Python, strip function in python
In the python API, describe the strip () function as follows:
Declaration: "s" is a string and "rm" is the sequence of characters to be deleted.
S. strip (rm) Delete the characters starting and ending in the s string and located in the rm Delete Sequence
S. lstrip (rm) Delete the characters starting from the s string in the rm Delete Sequence
S. rstrip (rm) deletes the characters at the end of the s string in the rm deletion sequence.
Note:
1. When rm is blank, blank spaces (including '\ n',' \ R', '\ t', '') are deleted by default ','')
For example:
>>> A = 'Hello world' >>> a 'hello world' >>>. strip () 'Hello world' >>> x = '\ t \ r \ npython' >>> x' \ t \ r \ npython' >>> x. strip () 'python'
2. The rm Delete sequence is deleted as long as the characters on the edge (beginning or end) are in the delete sequence.
For example:
>>> AString = '123love' >>> aString '123love' >>> aString. strip ('12') '3love'