因此,您有此代码可以在24位输出RGB值
print('#{:02x}{:02x}{:02x}'.format(r, g , b))
if (r % 17 == 0 and g % 17 == 0 and b % 17 == 0):
print('#{:01x}{:01x}{:01x}'.format(r/17, g/17, b/17))
else:
print('#{:02x}{:02x}{:02x}'.format(r, g , b))
如果您在8位中编码一个单声道颜色,则有256个值在0到255之间,因此您有255个间隔。如果您在4位中编码一个单声色的颜色,则具有16个值在0到15之间的值,因此您有15个间隔。
SO255 /15 => 17