Tutorialsteacher

Follow Us

Python - hex()

The hex() function converts a decimal integer into hexadecimal number with 0x prefix.

>>>hex(18)
'0x12'
>>>hex(255)
'0xff'
>>>hex(-64)
'-0x40'