Skip to content
Built-in Functions

bytes()

Create an immutable sequence of bytes.

bytes(source=b"")

bytes() stores byte values from 0 through 255. Use it for binary data that should not be changed in place.

Parameters

NameDescription
sourceOptional bytes, an iterable of integers, a string with an encoding, or a size.

Returns

A new immutable bytes object.

Try it

Run it and change it
codes = [65, 66]
data = bytes(codes)
print(data)

Related entries