String Methods
str.isspace()
Check that a nonempty string contains only whitespace according to Python’s Unicode rules: general category Zs or bidirectional class WS, B or S. Includes tabs, line breaks and nonbreaking spaces. Zero-width space and Persian zero-width non-joiner are not whitespace by this test. Use a domain-specific policy if invisible format characters matter. Takes no arguments.
Formal Syntax & Structure
python syntaxpython
text.isspace()Return Value
bool
True when the stated classification holds; otherwise False.
Working Example
Example Snippetpython
for text in (" ", "\t\n", "\u00a0", "\u200c", ""): print(ascii(text), text.isspace())