strip()
Removes leading and trailing whitespace.
Syntax
text.strip()
Description
Cleans up the whitespace/newline characters at the start and end of a string. If you pass characters in the parentheses, it removes those.
Returns
Cleaned new text.
Example
Loading editor…
Expected output
spacy title
When to use?
Cleaning up unwanted whitespace in text coming from a form or file.