Bytearray Methods
bytearray.append()
Append a single integer byte to the existing buffer. The value must be in the inclusive range 0–255 and support integer indexing. Use ord() for a single character only if its code point fits in a byte, or encode text and use extend(). An out-of-range integer raises ValueError; an unsupported type raises TypeError. An active buffer export prevents growth and raises BufferError.
Formal Syntax & Structure
python syntaxpython
data.append(item, /)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| item | int | SupportsIndex | One integer byte value from 0 through 255; not a one-byte bytes object. |
Return Value
None
None; modifies the existing buffer.
Working Example
Example Snippetpython
data = bytearray(b"AB")alias = dataprint(data.append(255))data.append(0)print(list(alias))print(data is alias)