Bytearray Methods
bytearray.isascii()
Check whether every byte lies between 0 and 127 inclusive; empty data also passes. Control bytes such as NUL and DEL qualify. This does not establish printability, token validity or the intended text encoding. Introduced in Python 3.7. The receiver is not modified. Returns a Boolean, not a transformed sequence. These operations are intended for ASCII-compatible data, not arbitrary binary formats.
Formal Syntax & Structure
python syntaxpython
data.isascii()Return Value
bool
True when the stated condition holds; False otherwise.
Working Example
Example Snippetpython
for token in (bytearray(b'API\x00'), bytearray(b'\x7f'), bytearray(b'\x80')): print(token, token.isascii())