[Tutor] revisiting struct and bytes again.
Luke Paireepinart
rabidpoobear at gmail.com
Wed Oct 4 19:56:55 CEST 2006
shawn bright wrote:
> Hey there,
>
> this time my question is a bit simpler.
> i can make a byte a string or number or whatever now. Up to the number
> 255.
> I now have a problem with something that comes in as a 4 byte
> representation of
> the number of seconds since 1970.
> I have been using ord(byte) to make sense of the messages so far, but
> i don't know how to add bytes greater than 255.
>
> the c program that sends us these defines the variable as an unsigned
> long int.
>
> anyone know how to make these four bytes a number of seconds ?
>
if you used struct it'd be easier, but...
do you know what order the bytes are in?
if they're big-endian just ord each individually and then you'll have a
4 digit base 256 number
convert this to base 10 so you can see what it is in regular integers
and use the time module to convert.
sorry I can't give more detail, I have to run, i'm late for class.
-Luke
> thanks
>
> sk
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list