What is the use of the strip () function in python
This article mainly introduces the use of the strip () function in python, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
Str.strip ()
Declare: s is a string and rm is the sequence of characters to be deleted
S.strip (rm) deletes the characters in the rm delete sequence at the beginning and end of the s string
S.lstrip (rm) deletes the character in the rm delete sequence at the beginning of the s string
S.rstrip (rm) deletes the character at the end of the s string in the rm delete sequence
1. When rm is empty, the space character is deleted by default (including'\ n _ blank,'\ r _ blank,'\ t _ blank,'')
For example:
> a = '123abc' > a.strip (' 21') '3abc' result is the same > a.strip (' 12') '3abc'
two。 The rm deletion sequence here deletes as long as the character on the edge (beginning or end) is in the deletion sequence.
For example:
> a = '123abc' > a.strip (' 21') '3abc' the result is the same > a.strip (' 12') '3abc' Thank you for reading this article carefully. I hope the article "what is the use of strip () function in python" shared by the editor is helpful to everyone. At the same time, I also hope you can support us, pay attention to the industry information channel, and more related knowledge is waiting for you to learn!