Methods to Convert HEX to RBG in Python
If you have to convert HEX (Hexadecimal) to RGB (Crimson-Inexperienced-Blue) in your Python code, then you are able to do the next:
Possibility 1 – Utilizing the PIL
library#
from PIL import ImageColor
hex = enter('Enter HEX worth: ')
ImageColor.getcolor(hex, "RGB")
Possibility 2 – Utilizing a customized resolution#
hex = enter('Enter HEX worth: ').lstrip('#')
print('RGB worth =', tuple(int(hex[i:i+2], 16) for i in (0, 2, 4)))