pythonwindowsvisual-studio-2022coloramatermcolor

How to print colored or bold text in Python Visual Studio 2022 CLI app


I have tried colorama, termcolor and printy.
When I run the application in debug method, the text isn't formatted.

This wasn't the case, when I built a C# Console application in VS.

Here is the code using printy.

from printy import printy

printy("Hello world", "rBU")

Output:

[38;5;196;1;4mHello world[0m

enter image description here

I have tried a few no-package solutions from here, but no luck. How do I print colored text to the terminal?

Is there any VS setting to configure?


Solution

  • Your terminal does not support the print arguments

    You either need to upgrade your Windows because it seems that your command line does not support the custom print arguments. Copy pasted your code to my Visual Studio and it works just fine.

    enter image description here