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

Accept-Encoding 'gzip' to make your cralwer faster

Python all any built-in function

lambda magic to find prime numbers