Skip to content

Home

RGB to hex

Converts the values of RGB components to a hexadecimal color code.

def rgb_to_hex(r, g, b):
  return ('{:02X}' * 3).format(r, g, b)

rgb_to_hex(255, 165, 1) # 'FFA501'

More like this

Start typing a keyphrase to see matching snippets.