The following English instructions are given by the official:
String.strip (s[, chars])
Return a copy of the string with leading and trailing characters removed. If chars is omitted or None, the whitespace characters is removed. If given and not None, chars must is a string; The characters in the string would be stripped from the both ends of the string this method is called on.
Changed in version 2.2.3:the chars parameter was added. The chars parameter cannot is passed in earlier 2.2 versions.
The characters in the following example are tab-header and end with a space.
Line= ' Hello happybks! ' Print ' * ' +line.strip () + ' * ' print ' * ' +line.strip (') + ' * ' print ' * ' +line.strip (') + ' * ' print ' * ' +line.strip (' h ') + ' * '
The output results are as follows:
*hello happybks!**hello Happybks!**hello happybks!** Hello happybks! *
Can be found to not pass parameters, will be the beginning and end of the string of the space, tab all Delete, the middle of the space and Tab will not
If you pass a space or tab argument, the substring will still delete the beginning and end of the string, regardless of the space or tab .
When the passed argument is a different argument, the string at the beginning of the argument is not the string, then there is no effect
However, if the beginning and end of the string are other strings, and the passed arguments are the same string, the string at the beginning and end of the strings is cleared, regardless of the number of arguments. But case sensitive.
For example, the following example:
line2= ' haaaaahhaaaaaaahhhhh ' print ' * ' +line2.strip (' h ') + ' * '
Python's String.strip (s[, chars]) method of various small details