[Python] How to print RGB colour to the terminal

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

  1. Stack

    Stack Membro Participativo

    Can ANSI escape code SGR 38 - Set foreground color with argument 2;r;g;b be used with print function? Example of use with code 33 is of course

    OKBLUE = '\033[94m'



    I would like to use 038 instead to be able to use any RGB color. Is that posible?

    I tried

    GREEN = '\038[2;0;153;0m'
    ENDC = '\033[0m'

    print(f"{GREEN} some text {ENDC}")



    Expected to change the color of "some text" in green

    Continue reading...

Compartilhe esta Página