Bytearray Methods
bytearray.splitlines()
Split binary data at LF (0x0A), CR (0x0D), or CRLF as a single boundary. Unlike str.splitlines(), vertical tab, form feed, other ASCII controls and non-ASCII line-separator encodings are not boundaries. A truthy keepends preserves the original delimiters. Empty data yields an empty list, and a final delimiter does not create an extra field. Returned fields are independent mutable bytearrays.
Formal Syntax & Structure
python syntaxpython
data.splitlines(keepends=False)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| keepends | bool | Truthy values preserve line endings; falsey values omit them. |
Return Value
list[bytearray]
List of bytearray lines, optionally retaining delimiters.
Working Example
Example Snippetpython
print(bytearray(b'A\r\nB\rC\n').splitlines())print(bytearray(b'A\r\nB\rC\n').splitlines(keepends=True))print(bytearray(b'A\x0bB\x85C').splitlines())