The strip() method in Python String returns a copy of the string where all the chars have been stripped right from the beginning and also the end of the string consisting of default whitespace characters. The strip() method thus returns a copy of the string that consists of both leading and trailing characters removed (depending on the string argument passed). The strip() method in Python string removes the characters from both left as well as right depending on the argument (a string that specifies the set of characters that are to be removed).
Here is the syntax for strip() method:
This method in Python string returns true if in case it is found matching with the string otherwise false.
The following example below shows the usage of startswith() method.
#!/usr/bin/python str = "0000000this is string example....wow!!!0000000"; print str.strip( '0' )
When the above program is run, it produces the following result:
this is string example....wow!!!
Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.