PHP like trim function in Python

Does python have any trim() function (like php) to remove the leading and trailing whitespace? Answer is yes and it's called strip. Here is the code:
>>> str = ' aa b cde  '
>>> str
' aa b cde  '
>>> str.strip()
'aa b cde'
>>> str = str.strip()
>>> str
'aa b cde'
>>> 
Happy Coding! :)

Comments

Popular posts from this blog

Python all any built-in function

Accept-Encoding 'gzip' to make your cralwer faster

lambda magic to find prime numbers