Bytes Methods

bytes.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 (bytes(b'042'), bytes(b'-42'), bytes(b'3.14')):    print(token, token.isdigit())
Python Reference