bytes.strip([chars])
bytearray.strip([chars])
Return a copy of the sequence with specified leading and trailing bytes removed. The chars argument is a binary sequence specifying the set of byte values to be removed - the name refers to the fact this method is usually used with ASCII characters. If omitted or None
, the chars argument defaults to removing ASCII whitespace. The chars argument is not a prefix or suffix; rather, all combinations of its values are stripped:
1 2 3 4 | >>> b ' spacious ' .strip() b 'spacious' >>> b 'www.example.com' .strip(b 'cmowz.' ) b 'example' |
The binary sequence of byte values to remove may be any bytes-like object.
Note
The bytearray version of this method does not operate in place - it always produces a new object, even if no changes were made.
Please login to continue.