Bytearray Methods
bytearray.isdigit()
Check for a nonempty sequence containing only ASCII digits 0–9. A sign, decimal point, space or non-ASCII digit encoding fails. Use decoding and the appropriate Unicode or numeric parsing operation for other textual number formats. 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.isdigit()Return Value
bool
True when the stated condition holds; False otherwise.
Working Example
Example Snippetpython
for token in (bytearray(b'042'), bytearray(b'-42'), bytearray(b'3.14')): print(token, token.isdigit())