[Tutor] how to separate hexadecimal

Max Noel maxnoel_fr at yahoo.fr
Wed Feb 2 12:31:09 CET 2005


On Feb 2, 2005, at 10:19, Ewald Ertl wrote:

> Hi!
>
> Using binary operations:
>
>>>> a='0x87BE'
>>>> str(hex(int(a,16) & 0xFF))
> '0xbe'
>>>> str(hex((int(a,16) & 0xFF00) / 0xFF))
> '0x87'
>>>>
>
> HTH Ewald

	Actually, the int conversions aren't even necessary.

 >>> hex(0x87BE & 0xFF)
'0xbe'
 >>> hex((0x87BE & 0xFF00) / 0xFF)
'0x87'


-- Max
maxnoel_fr at yahoo dot fr -- ICQ #85274019
"Look at you hacker... A pathetic creature of meat and bone, panting 
and sweating as you run through my corridors... How can you challenge a 
perfect, immortal machine?"



More information about the Tutor mailing list