Answers for "convert hex code to rgb python"

3

rgb to hex python

from colormap import rgb2hex
from colormap import hex2rgb

print(rgb2hex(255, 255, 255))
print(hex2rgb('#FFFFFF'))

>>> #FFFFFF
>>> (255, 255, 255)
Posted by: Guest on October-31-2020
1

hex to rgb python

def hex2rgb(color):
  hex = color.lstrip('#')
  rgb = tuple(int(hex[i:i+2], 16) for i in (0, 2, 4))
  
  return rgb

hex_color = "#B4FBB8"
rgb_color = hex2rgb(hex_color)

print(rgb_color)
#(180, 251, 184)
Posted by: Guest on June-16-2021

Python Answers by Framework

Browse Popular Code Answers by Language