by = b'\x01\x02' print(by) by = by.rstrip() print(by) by = by.rstrip(chr(2).encode()) print(by)
b'\x01\x02'b'\x01\x02'b'\x01'