Bytes Methods
bytes.rstrip()
Remove consecutive eligible byte values from the end. With no argument or None, remove ASCII whitespace (space, tab, LF, CR, vertical tab and form feed). An explicit buffer supplies individual byte values, not a literal substring. Internal bytes and high-byte values outside the selected set stay unchanged. An empty argument removes nothing. Returns bytes.
Formal Syntax & Structure
python syntaxpython
data.rstrip(chars=None, /)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| chars | bytes-like | None | Set of removable byte values; None selects ASCII whitespace. |
Return Value
bytes
bytes with selected edge byte values removed.
Working Example
Example Snippetpython
print(bytes(b' \tABC\r\n').rstrip())print(bytes(b'xyxDATAyxx').rstrip(b'xy'))print(bytes(b'\xa0 A \xa0').rstrip())