[Tutor] packet parsing

Remco Gerlich scarblac@pino.selwerd.nl
Thu, 28 Feb 2002 22:34:49 +0100

On  0, python@jayed.com wrote:
> > The string *is* the binary stream. A string is just a bunch of bytes.
> That's what I thought.  But "print kexrecv" returns nothing in the
> interpreter. 

Probably they're all unprintable bytes then, like null bytes.

> I just get ">>>" back.  "print kexrecv.capitalize()"
> returns nothing.  "kexrecv.capitalize()" returns a repr() type value
> "'\x00\x00..."

Right, null bytes.

> OK, that makes sense.  But how do I peel of individual bytes?  (I just
> played with lstrip and am not having any luck -- but this is probably my
> lack of knowledge).

kexrecv[0] is the first byte, kexrecv[1] the second, etc.


for byte ik kexrecv:
   print ord(byte)
To see the integer values.

And now, Roda JC has scored in Milan! PSV is equal vs Leeds!
(back to watching football :))

Remco Gerlich