python bytes类型去除尾部字节
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'
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'