Why does termcolor output control characters instead of colored text in the Windows console?

To make the ANSI colors used in termcolor work with the windows terminal, you’ll need to also import/init colorama;

>>> from termcolor import *
>>> cprint('hello', 'red')
←[31mhello←[0m
>>> import colorama
>>> colorama.init()
>>> cprint('hello', 'red')
hello                                    <-- in red color
>>>

Leave a Comment