Posts

Showing posts with the label space character

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! :)