Given an integer, this function returns a string displaying that value in hexadecimal (base 16).
>>> hex(15) '0xf' >>> hex(255) '0xff' >>> hex(256) '0x100' >>> hex(1325178541275812780L) '0x1263fadcb8b713ac'
See also Section 9.4, “The string .format() method”: hexadecimal
conversion is supported by specifying a code of type'x' or 'X'.