Language Syntax

Bytes literal — Python syntax

Construct immutable bytes from ASCII source characters and byte escapes. Non-ASCII text must be encoded or represented with escapes; a bytes literal does not automatically encode arbitrary Unicode text.

Formal Syntax & Structure

python syntaxpython
b"ASCII characters and escapes"

Return Value

bytes

Value obtained by evaluating this expression; see description for context and constraints.

Working Example

Example Snippetpython
data=b'A\xff'print((list(data),data.hex()))
Python Reference