Integer to Hexadecimal Conversion in Python

hex, int, python

Solution

You can use `format` :

>>> a = 1
>>> '{0:02x}'.format(a)
'01'
>>> '0x{0:02x}'.format(a)
'0x01'

Problem

``` a = 1 print hex(a) ``` The above gives me the output: `0x1` How do I get the output as `0x01` instead?

Original source

Related problems