786
Comment:
|
← Revision 10 as of 2011-03-26 23:10:50 ⇥
1338
Added categories.
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
## page was renamed from How can I convert a hex representation to an integer? | |
Line 17: | Line 18: |
["lwickjr"]: you use | ['anon']: try {{{ #!python >>> 0x00cc15a4 13374884 |
Line 19: | Line 24: |
}}} [[lwickjr]]: you use {{{ #!python |
|
Line 22: | Line 35: |
}}} | |
Line 24: | Line 38: |
YerMat: See module [[http://docs.python.org/lib/module-struct.html|struct]] ! {{{ #!python >>> import struct >>> struct.unpack('I', '\x00\xcc\x15\xa4') (2752891904L,) >>> struct.unpack('i', '\x00\xcc\x15\xa4') (-1542075392,) >>> }}} == See Also == * BitManipulation has a bunch on working with hex ---- CategoryAskingForHelp CategoryAskingForHelpAnswered |
Converting a Hex representation to an Integer
I'm running into some trouble when trying to convert a series of hex representations into an integer... I'm sure there is a builtin to do this (wouldn't make sense not to have one) but I can't find it for the life of me.
This is a dump of my interpreter session:
and I need to convert the values following user ('\x00\xcc\x15\xa4') into an integer value... what am I doing wrong here?
['anon']: try
lwickjr: you use
...but these aren`t hex values. Try ord() on each character, and see if that gives you the results you need.
See module struct !
See Also
BitManipulation has a bunch on working with hex