PRINT COLORED TEXT IN PYTHON

This is just a brief intro about these two color text generator libraries of python, you can do more thing like blinking text.

USING COLORAMA

print(Fore.BLUE + “Blue Text”)

print(Back. RED + “Red Background”)

print(Style. BRIGHT +”Bright text”)

print(Style.RESET_ALL + “Normal Text”)

Output

Blue Text

Red Background

Bright text

Normal Text

USING TERMCOLOR

from termcolor import colored, cprint

print( colored( ‘Blue Text, World!’,’blue’))

cprint(‘Red Background’,’grey’,’on_red’)

print(colored(‘Bold’,attrs = [‘bold’]))

print(colored(‘Underlined’ , attrs=[‘underline’]))

Output

Blue Text, World!

Red Background

Bold

Underlined

Leave a comment

Design a site like this with WordPress.com
Get started