Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个函数,它返回一个从 0 到 255 的浮点数。我想从中制作一个红色渐变,但我需要一个“#FFFFFF”格式的字符串。有那个功能吗?
你可以使用:
"#%02X0000" % x
def rgbtohex(r,g,b): return "#%02X%02X%02X" % (r,g,b)