def hex_color_to_tuple ( hex ) : hex = hex [ 1 : ] length = len ( hex ) // 2 return tuple ( int ( hex [ i * 2 : i * 2 + 2 ] , 16 ) for i in range ( length ) )
html color to rgb tuple python
convent hex color to tuple #ffffff - > ( 255 255 255 ) #ffff00ff - > ( 255 255 0 255 )
def hex_color_to_tuple(hex):
    """ convent hex color to tuple
    "#ffffff"   ->  (255, 255, 255)
    "#ffff00ff" ->  (255, 255, 0, 255)
    """
    hex = hex[1:]
    length = len(hex) // 2
    return tuple(int(hex[i*2:i*2+2], 16) for i in range(length))