all Python 3Byte sequencesfunction
bytes.lstrip
bytes — stripping
Return a copy with the given bytes removed from the left; by default strips ASCII whitespace.
Syntax
b.lstrip(...)
The argument is a set of byte values, not a prefix: stripping proceeds byte by byte from the left while each byte belongs to that set, so b'abcabd'.lstrip(b'ab') leaves b'cabd'. Trimming leading zeros bites here — b'0000'.lstrip(b'0') yields an empty b'', not b'0'. To drop one known leading chunk, use removeprefix().
Examples
print(b' hi'.lstrip()) # → b'hi'
print(b'xxxdata'.lstrip(b'x')) # → b'data'
print(b'0042'.lstrip(b'0')) # → b'42'
print(b'abcabd'.lstrip(b'ab')) # → b'cabd'
print(b' hi '.lstrip()) # → b'hi '
See also
Open in the full glossarydocs.python.orgReport an inaccuracy