[Tutor] convert decimal to hexa, to octal and vice versa.

Noufal Ibrahim noufal at nibrahim.net.in
Wed Apr 5 13:50:14 CEST 2006


On Wed, April 5, 2006 5:02 pm, Keo Sophon wrote:
> Hi,
>
> How to convert a decimal number to hexadecimal, octal and vice versa?

>>> foo = 2
>>> str(foo) # Integer to string
'2'
>>> oct(15)  # Integer to octal
'017'
>>> hex(15)  # Integer to hex
'0xf'
>>> int(0xf) # Hex to decimal integer


-- 
-NI



More information about the Tutor mailing list