all Python 3Byte sequencesfunction
bytearray.lstrip
bytearray — stripping
Return a copy with the given bytes removed from the left; by default strips ASCII whitespace.
Syntax
ba.lstrip(...)
The argument is a set of byte values peeled off one at a time while they keep matching, not a prefix taken as a whole: lstrip(b'xy') eats any run of 'x' and 'y' in any order. To drop exactly one given sequence, reach for removeprefix. The bytearray itself is untouched — you get a new object back.
Examples
print(bytearray(b' hi').lstrip()) # → bytearray(b'hi')
print(bytearray(b'\t\n hi').lstrip()) # → bytearray(b'hi')
print(bytearray(b'000123').lstrip(b'0')) # → bytearray(b'123')
print(bytearray(b'xyxdata').lstrip(b'xy')) # → bytearray(b'data')
print(bytearray(b' hi ').lstrip()) # → bytearray(b'hi ')
print(bytearray(b'0000').lstrip(b'0')) # → bytearray(b'')
See also
Open in the full glossarydocs.python.orgReport an inaccuracy