This article mainly introduces Python's use of the Strip () method to remove the string hollow, is the basics of Python introductory learning, need friends can refer to the
The Strip () method returns a copy of all characters from the beginning and the end of the string (the default space character) after being stripped of the string.
Grammar
The following is the syntax for the Strip () method:
?
Parameters
Chars--characters--from the start or end of the string are removed.
return value
This method returns a copy of all characters from the beginning and the end of the string (the default space character) after being stripped of the string.
Example
The following example shows the use of the Strip () method.
?
1 2 3 4 |
#!/usr/bin/python str = "0000000this is string EXAMPLE....WOW!!! 0000000 "; Print Str.strip (' 0 '); |
When we run the above program, it produces the following results:
?
|
is St Ring EXAMPLE....WOW!!! |