Converting 2 bytes string into INT

John Hunter jdhunter at nitace.bsd.uchicago.edu
Fri Jul 12 12:25:44 EDT 2002


>>>>> "DeDa" == DeDa  <deda at mypad.com> writes:

    DeDa> Hi to all, I'm a newbie of Python and I already have a big
    DeDa> problem. I read 2 bytes from files and I like to convert
    DeDa> them into an integer. How can I do it?  Thanks a lot.  Bye,
    DeDa> DeDa.

See the struct module and it's unpack function: 

  http://python.org/doc/current/lib/module-struct.html

For more info, take a look at:

http://groups.google.com/groups?as_q=read%20binary&safe=images&ie=ISO-8859-1&as_ugroup=comp.lang.python&lr=&hl=en

Cheers,
John Hunter



More information about the Python-list mailing list