Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

remove trailing and leading spaces in python

text = "   Hello World        "
text.strip()
# Hello World
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

PREVIOUS NEXT
Code Example
Python :: english to japanese 
Python :: mario dance dance revolution 
Python :: python remove during iteration 
Python :: Plotting keras model trainning history 
Python :: new event loop asyncio 
Python :: avatar discord.py 
Python :: pygame doesnt dedect collision between sprite and image 
Python :: remove duplicate row in df 
Python :: python print without space 
Python :: python intersection of two lists 
Python :: start new app in django 
Python :: average within group by pandas 
Python :: Why do we use graphs? 
Python :: python little endian to big endian 
Python :: file to lowercase python 
Python :: change each line color as a rainbow python 
Python :: discord.py how to give a user a role 
Python :: pyqt pylatex 
Python :: all column except pandas 
Python :: You did not provide the "FLASK_APP" environment variable 
Python :: delete turtle 
Python :: python change format of datetime 
Python :: python temporary files 
Python :: add header to table in pandas 
Python :: save timestamp python 
Python :: how to add 2 dates in python 
Python :: dot product python 
Python :: py insert char at index 
Python :: python snake game 
Python :: python title case 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =