2

Using ANSI escape sequence, I can change the color of text that python prints. The example below prints "Hi World" in light blue.

#!/usr/bin/python3
print(f'\033[38;5;117mHi World')

While this works I am limited to just 256 colors. Are there any terminals or extensions that allow me to print colors in hex triplets #000000-#FFFFFF using python?

1 Answer 1

3

Yes, there are, but not all terminals support it, some do it differently than others, you need to figure out what your terminal's capabilities are... In other words: it's possible, but you don't want to do it yourself.

The standard way of doing it is hence using a library, in the Python casr that would probably be Rich or Textual, depending on whether you just want pretty colorful text or also prompts, buttons, tables etc.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .