Home > Article > Backend Development > What does strip mean in python?
Strip in python is a method in strings.
The Python strip() method is used to remove specified characters (spaces by default) or character sequences at the beginning and end of a string. (Recommended learning: Python video tutorial)
Note: This method can only delete the beginning or end characters, but not the middle characters.
strip() method syntax:
str.strip([chars]);
Parameters
chars -- Remove the beginning and end of the string The specified character sequence.
Return value
Returns a new string generated by removing the specified character sequence from the beginning and end of the string.
Examples
The following examples show how to use the strip() function:
#!/usr/bin/python3 str = "*****this is **string** example....wow!!!*****" print (str.strip( '*' )) # 指定字符串 *
The output results of the above examples are as follows:
this is **string** example....wow!!!
From the results, you can notice that the characters in the middle part have not been deleted.
For more Python related technical articles, please visit the Python Tutorial column to learn!
The above is the detailed content of What does strip mean in python?. For more information, please follow other related articles on the PHP Chinese website!