Skip to content
masterclass Buddy

Python · Class

bytearray

bytearray() creates a mutable sequence of bytes. You can build it from text, a size, a buffer, or an iterable of byte values.

Last updated

Syntax

bytearray(source=b'')
bytearray(source, encoding, errors='strict')

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • bytes
  • memoryview
  • str.encode()
  • Mutable Sequence Types

Source: Built-in functions — Python 3.16.0a1 documentation. Checked 2026-11-03.