← Go Back
To get the decimal number back, use the int() function:
How to Convert Decimal to Hexadecimal (And Vice Versa)
Thehex()
built-in function takes an integer and returns its hexadecimal representation as a string:>>> hex(255)
'0xff'
To get the decimal number back, use the int() function:
# The '0x' prefix is optional.
>>> int("0xff", 16)
255
🐍 You might also find interesting: