1

I am trying convert decimal color to hexadecimal.

For example, yellow color is #FFFF00 and there decimal is 16776960.

How can I convert to hexadecimal ( #FFFF00 ) from decimal ( 16776960 ) ?

I tried to use this:

color = 16776960
hex(color)

and tried with hex(int(color))

Paul
  • 10,381
  • 13
  • 48
  • 86
Accesito
  • 41
  • 6
  • 4
    Possible duplicate of [Convert hex string to int in Python](http://stackoverflow.com/questions/209513/convert-hex-string-to-int-in-python) – simon May 04 '16 at 22:31
  • 1
    FYI, colors are usually hex triplets. Is it really meaningful to have a decimal representation of the whole string? I'd think you'd want `#FFFF00` to map to `(256, 256, 0)`. Though reading closely it looks like you already have the decimal color, for some reason. – Paul May 04 '16 at 22:51

1 Answers1

3

I solved my problem, sorry for inconvenice.

xxxs = int(xxx)
color = hex(xxxs).replace("0x", "")
print "color to hexa "+str(color)+""
this.c.colornick = "#"+str(color)
Accesito
  • 41
  • 6