packet=bytes([0,3])+b"cat" length=int.from_bytes(packet[:2],"big") assert length<=100 and len(packet)-2==length print(packet[2:].decode())