ReferenceString methods
str.strip()
Removes whitespace, or any of the given characters, from both ends.
Signature
text.strip(chars=None)Parameters
| Name | Means |
|---|---|
chars | a set of characters to remove; whitespace when omitted |
Returns
A new string.
Example
Python
print(repr(" hello ".strip()))
print("xxhixx".strip("x"))
print("www.example.com".strip("wmoc."))Output
'hello' hi example