[Python] How Do I Get Python to Output In RGB Color on a Windows Terminal?

Discussão em 'Python' iniciado por Stack, Julho 9, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using a simple python (3.9.2) interpreter via command prompt on a windows 10 machine.

    I am trying to get colored output texts from the python interpreter. I know how to get colored outputs however I'm looking for something that would allow RGB specified inputs so that I may output varying color intensities.

    I found one thread HERE with such an example (you may have to scroll down to see the code line specifying the RGB input).

    so.. I tried this part: (I also had to import colorama for ANY of the escape sequences to display actual color)

    from sty import fg, bg, ef, rs

    foo = fg.red + 'This is red text!' + fg.rs
    qui = fg(255, 10, 10) + 'This is red text using 24bit colors.' + fg.rs

    # Add custom colors:

    from sty import Style, RgbFg

    fg.orange = Style(RgbFg(255, 150, 50))

    buf = fg.orange + 'Yay, Im orange.' + fg.rs

    print(foo, bar, baz, qux, qui, buf, sep='\n')


    The fg.red worked okay, but the RGB specified lines did not produce the correct colors. nor the intensities. Is there anything else for suggestions where I can get this to work on a windows machine??

    Continue reading...

Compartilhe esta Página