[Tutor] Re: how to separate hexadecimal

Alan Gauld alan.gauld at freenet.co.uk
Wed Feb 2 10:07:32 CET 2005


>  >>> hexa = '0x87BE'
>  >>> upper = int(hexa[2:4], 16)
>  >>> lower = int(hexa[4:6], 16)

FWIW :
You don't need to strip the '0x' from the front, int() is 
smart enough to do that automatically for base 16 
conversions...

Alan G.


More information about the Tutor mailing list