Rstrip, strip, lstrip

Source: Internet
Author: User

The rstrip, strip, and lstrip functions are mainly used to remove the character that meets the conditions in the string. The input parameters are a character array, which respectively indicate matching and removing the characters on the right, both sides, and left.

When no parameter is input, strip () indicates removing spaces at the beginning and end. The same applies to the other two functions.

Code:

>>> STR = '\ tgood to say you, you are a good guys! Doddoog! \ N'
>>> Nospace = Str. Strip ()
>>> Nospace
'Good to say you, you are a good guys! Doddoog! '
>>> Nospace. Strip ('Go! Od ')
'To say you, you are a good guys'
>>> Nospace. lstrip ('Go! Od ')
'To say you, you are a good guys! Doddoog! '
>>> Nospace. rstrip ('Go! Od ')
'Good to say you, you are a good guys'
>>>

Str. rstrip ('\ n \ R') is the most used in applications, and a line break is used between systems.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.