Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python string trim

string ='   abc   '

# After removing leading whitespace
print(string.lstrip());
# Output: 'abc   '

# After removing trailing whitespace
print(string.rstrip());
# Output: '   abc'

# After removing all whitespace
print(string.strip());
# Output: 'abc'
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #string #trim
ADD COMMENT
Topic
Name
2+6 =