bytes object

A Python value holding raw bytes, numbers from 0 to 255, written like b"abc", as opposed to a string of characters.

In more detail

Call encode on a string to get bytes and decode on bytes to get a string back, for example text.encode("utf-8") and data.decode("utf-8"). Files opened in binary mode, such as "rb", read and write bytes, and network and storage libraries work with bytes too, so text must be encoded first.

Examples

b'payload'
Kafka keys, values and header values are bytes.
'value'.encode()
"café".encode("utf-8")

Related terms

Taught in

References