How do I print colored/bold output to the terminal in Python?

Reference: StackOverFlow

The last comment on the above link works for windows.

But not on IDE’s integrated consoles.

For Python 3, non-windows:

from termcolor import colored
print(colored('Hello, World!', 'green', 'on_red'))

 

For windows: 

from colorama import init
from termcolor import colored

# use Colorama to make Termcolor work on Windows too
init()

# then use Termcolor for all colored text output
print(colored('Hello, World!', 'green', 'on_red'))

Leave a comment