Re: convert binary data to int

2007-01-10 Thread Paul Sijben
in some cases struct.unpack would also help [EMAIL PROTECTED] wrote: > Hello, > > > I need to convert a 3 byte binary string like > "\x41\x00\x00" to 3 int values ( (65,0,0) in this case). > The string might contain characters not escaped with a \x, like > "A\x00\x00" > > > Any ideas? > > >

Re: convert binary data to int

2007-01-10 Thread rubbishemail
[ord(x) for ...] perfect, thank you Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: convert binary data to int

2007-01-10 Thread Gabriel Genellina
At Wednesday 10/1/2007 07:17, [EMAIL PROTECTED] wrote: I need to convert a 3 byte binary string like "\x41\x00\x00" to 3 int values ( (65,0,0) in this case). The string might contain characters not escaped with a \x, like "A\x00\x00" py> [ord(x) for x in "\x41\x00\x00"] [65, 0, 0] py> [ord(x)

Re: convert binary data to int

2007-01-10 Thread Laurent Pointal
[EMAIL PROTECTED] a écrit : > Hello, > > > I need to convert a 3 byte binary string like > "\x41\x00\x00" to 3 int values ( (65,0,0) in this case). > The string might contain characters not escaped with a \x, like > "A\x00\x00" > > > Any ideas? >>> s = "\x41\x00\x00" >>> [ ord(c) for c in s ]

Re: convert binary data to int

2007-01-10 Thread Peter Otten
[EMAIL PROTECTED] wrote: > I need to convert a 3 byte binary string like > "\x41\x00\x00" to 3 int values ( (65,0,0) in this case). > The string might contain characters not escaped with a \x, like > "A\x00\x00" >>> [ord(c) for c in "A\x00\x41"] [65, 0, 65] For more complex conversions look into

convert binary data to int

2007-01-10 Thread rubbishemail
Hello, I need to convert a 3 byte binary string like "\x41\x00\x00" to 3 int values ( (65,0,0) in this case). The string might contain characters not escaped with a \x, like "A\x00\x00" Any ideas? Daniel -- http://mail.python.org/mailman/listinfo/python-list