The use of whitespace functions in python

  • 2020-04-02 13:58:03
  • OfStack

This article briefly introduces the use of space function in Python, which is a very practical function, I hope to help you in Python programming. Specific analysis is as follows:

In Python, there are three whitespace functions in the string handling function:

strip Remove the left and right Spaces
lstrip Remove the Spaces on the left
rstrip Remove the space on the right

Specific examples are as follows:


>>>a=" gho stwwl "
>>>a.lstrip()
'gho stwwl '
>>>a.rstrip()
' gho stwwl'
>>>a.strip()
'gho stwwl'

Those interested can test the above example code to get a better idea of how the function is used.


Related articles: