This is one of those silly questions and I don't really know how to formulate it, so I'll give an example. I got
v = chr(0xae) + chr(0xae)
where #AEAE is, in decimal, the value of 44718.
My question is how I get the integer value of v
? I know about ord()
but I can use it only for a char, and not for a string.
Thank you.
I managed to do this using the struct
module:
import struct
int_no = struct.unpack('>H', v)[0]
print int_no
which outputs the desired results:
44718
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With