I know this may be an incredibly easy answer but I couldn't find the answer to this so is there an easy way to convert between hex and decimal and binary and hex in python like the way you can convert from decimal to binary with int()
?
Thanks in advance for your answers. - Ed
Asked
Active
Viewed 334 times
0

Music Champ29
- 67
- 1
- 1
- 8
-
Thank you Reblochon. Didn't see that question! – Music Champ29 May 14 '14 at 15:40
1 Answers
1
Yes, it's quite easy:
>>> hex(33)
'0x21'
>>> oct(33)
'041'
>>> bin(33)
'0b100001'
>>> int('0x21', 16)
33
>>> int('041', 8)
33
>>> int('0b100001', 2)
33

Holt
- 36,600
- 7
- 92
- 139