Madhusudan Singh wrote:
> I just tried 
> 
> n=str(x)
> print struct.unpack("b",n)
> 
> I get (51,)
> 
> What is the deal with the parenthesis
> and the comma ?

If you really don't know what the parentheses and comma mean in the 
above output, I would suggest that you need to go back a step and walk 
through the Python tutorial before you try to continue on with what you 
are attempting to do.  (Section 5.3 specifically covers your question.) 
  Either that, or read the documentation on struct.unpack() since that 
describes what it returns fairly clearly.

Assuming your input represents a C-style integer (i.e. fixed size) 
rather than a Python long integer (of arbitrary length), you should be 
able to use just struct.unpack('i', mybinarydata)[0] to get the result 
you need...

-Peter
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to