Been racking my brain on how to convert string color to hex triplet.
Example convert gold to ffd700.
I know that for rgb this is ff(red) d7(green) 00(blue).
I can get the 8 bit hex and 16 bit hex values but, can't for the life of me figure out how to get the hex triplet. Any direction or guidance much appreciated.
My convert func for string to hex
Example convert gold to ffd700.
I know that for rgb this is ff(red) d7(green) 00(blue).
I can get the 8 bit hex and 16 bit hex values but, can't for the life of me figure out how to get the hex triplet. Any direction or guidance much appreciated.
My convert func for string to hex
def colors(color): color = color.encode('utf-8') hex_color = color.hex() print(hex_color) # or using 16 bit def colors(color): color = color.encode('utf-16') hex_color = color.hex() print(color) colors('golden')
Output:676f6c64656e
#output 2
b'\xff\xfeg\x00o\x00l\x00d\x00e\x00n\x00'
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
Download my project scripts
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
Download my project scripts