Python Glossary Русский

all Python 3Byte sequencesfunction

bytearray.isspace

bytearray — is* checks

All bytes are whitespace and non-empty.

Syntax

ba.isspace(...)

Only ASCII whitespace counts here: space, \t, \n, \r, \v, \f. Byte 0xa0 (a non-breaking space in latin-1) is not in that set, even though str.isspace() answers True for the character '\xa0' — if the bytes came from text, decode first and test the resulting string.

Examples

print(bytearray(b'   ').isspace())   # → True
print(bytearray(b' \t\n').isspace())   # → True
print(bytearray(b' a ').isspace())   # → False
print(bytearray(b'').isspace())   # → False
print(bytearray(b' \t ').strip())   # → bytearray(b'')

See also

Open in the full glossarydocs.python.orgReport an inaccuracy