ID EN
Built-in Types

bytearray

Python 3.11

There is no dedicated literal syntax for bytearray objects, instead they are always created by calling the constructor:

Syntax

PYTHON
class bytearray([source[, encoding[, errors]]])

Examples

Example 1
PYTHON
>>> bytearray.fromhex('2Ef0 F1f2  ')
bytearray(b'.\xf0\xf1\xf2')
Example 2
PYTHON
>>> bytearray(b'\xf0\xf1\xf2').hex()
'f0f1f2'

See Also

mutable Bytes and Bytearray Operations bytearray bytearray bytearray.fromhex() bytes.hex() bytearray.hex()