Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python trim whitespace from end of string

>>> "    xyz     ".rstrip()
'    xyz'
Comment

Python trim leading and trailing whitespace()

Use the strip() method
Example

>>> name = '  Steve  ' 
>>> name
'  Steve  '
>>> name = name.strip()
>>> name
'Steve'
Comment

Trim leading whitespace in Python

Use the rstrip() method
Example

>>> name = '  Steve  ' 
>>> name
'  Steve  '
>>> name = name.rstrip()
>>> name
'  Steve'
Comment

Trim trailing whitespace in Python

Use the lstrip() method

>>> name = '  Steve  ' 
>>> name
'  Steve  '
>>> name = name.lstrip()
>>> name
'Steve  '
Comment

PREVIOUS NEXT
Code Example
Python :: convert list to set python 
Python :: get local ipv4 
Python :: jupyter notebook not working 
Python :: integral python 
Python :: extract DATE from pandas 
Python :: how to reset username and password in django admin 
Python :: plotly go axis labels 
Python :: parentheses in python 
Python :: starting variable name with underscore python 
Python :: save model python 
Python :: python create a dictionary of integers 
Python :: python possible combinations 
Python :: filter dict by list of keys python 
Python :: python numpy delete element from array 
Python :: python try and except 
Python :: difference between method and function in pyhon 
Python :: apyori 
Python :: graph a line from dataframe values over a bar plot in python 
Python :: python extract substring 
Python :: range(len()) in python 
Python :: django serve media folder 
Python :: how to add coloumn based on other column 
Python :: if-else 
Python :: django queryset to list 
Python :: pandas count 
Python :: cv2 imwrite 
Python :: matplotlib histogram python 
Python :: beautifulsoup usage 
Python :: tkinter treeview clear 
Python :: tf MaxPooling2D 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =