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
No you can't convert using str(). Binary data is
stored in a Python string object, but it isn't really
a string. It is rather just a bunch of bits packed
into a string variable. struct.unpack() will unpack
those bits into any number of different types of
variables and is what you need.
Hi
I am using binascii.b2a_hex to convert some binary data to hex. The result
is a two bit hex representation (i. e., without the leading 0x). How do I
convert the resulting two bit representation into an integer ?
Thanks.
--
http://mail.python.org/mailman/listinfo/python-list
Can you give us an example. I don't know what two bit
hex means (takes at least 4 bits to make a hex digit).
Now I'm going to try to guess:
If the data is binary then all you need to do is to
use the struct.unpack module to convert to integer.
Larry Bates
Madhusudan Singh wrote:
Hi
I am
Larry Bates wrote:
Can you give us an example. I don't know what two bit
hex means (takes at least 4 bits to make a hex digit).
Like 64(base 16)=100.
I am referring to 64 in the above.
Now I'm going to try to guess:
If the data is binary then all you need to do is to
use the
Madhusudan Singh wrote:
Larry Bates wrote:
Can you give us an example. I don't know what two bit
hex means (takes at least 4 bits to make a hex digit).
Like 64(base 16)=100.
I am referring to 64 in the above.
Now I'm going to try to guess:
If the data is binary then all you need
Madhusudan Singh wrote:
Can you give us an example. I don't know what two bit
hex means (takes at least 4 bits to make a hex digit).
Like 64(base 16)=100.
I am referring to 64 in the above.
that's two digits, not two bits.
print int(64, 16)
100
Now I'm going to try to guess:
Madhusudan Singh wrote:
I am using binascii.b2a_hex to convert some binary data to hex. The
result is a two bit hex representation (i. e., without the leading
0x).
Surely you mean two-byte?
How do I convert the resulting two bit representation into an integer
?
int(foo, 16)
--