Bytearray Methods
bytearray.rsplit()
Split binary data at a literal nonempty bytes-like separator, or at runs of ASCII whitespace when sep is None. With a nonnegative split limit, choose matches from the right; output fields remain in original order. Explicit separators preserve empty fields, whereas whitespace mode discards edge whitespace when splitting without a limit. With maxsplit=0, whitespace mode only removes trailing whitespace. Empty explicit separators raise ValueError. Non-ASCII whitespace encodings are not recognized. Each field is an independent bytearray.
Formal Syntax & Structure
python syntaxpython
data.rsplit(sep=None, maxsplit=-1)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| sep | bytes-like | None | Nonempty literal separator; None selects ASCII whitespace splitting. |
| maxsplit | int | Maximum splits; negative means unlimited. |
Return Value
list[bytearray]
List of bytearray fields in original order.
Working Example
Example Snippetpython
print(bytearray(b'a:b:c').rsplit(b':', 1))print(bytearray(b' a b ').rsplit())print(bytearray(b'a,,b,').rsplit(b','))