Computer Studies‎ > ‎Python‎ > ‎References‎ > ‎

Converting Hex to Int

# input
hex_val = 'FF'

# process
# Note the 2nd argument in the int() function!
dec_value = int(hex_val, 16)

# output
print(hex_val, 'in hex equals', dec_value, 'in decimal.')





...outputs:

FF in hex equals 255 in decimal.
Comments