Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the use of the strip () function in python

Shulou Source: shulou.com Published: 2022-06-01 02:56:05 10月03日 Update

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!

Tags: Character sequence string article beginning function end result value interest at the same time more friends knowledge blank blank character ribbon industry information information channel Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Shulou Information Linux Apple MariaDB