Latest web development tutorials

Python strip () method

Python strings Python strings


description

Python strip () method is used to remove the head and tail of the specified character string (default is a space).

grammar

strip () method syntax:

str.strip([chars]);

parameter

  • chars - remove the head and tail of the specified character string.

return value

Remove the head and tail string Returns new string specified character generation.

Examples

The following example shows the strip () function to use:

#!/usr/bin/python

str = "0000000this is string example....wow!!!0000000";
print str.strip( '0' );

Examples of the above output results are as follows:

this is string example....wow!!!

Python strings Python strings