I want to add text color while print output. How to do that ?
Example: Print('Hello Everyone.')
I want output text
Hello Everyone
will highlighted red color.
Thanks you!
I want to add text color while print output. How to do that ?
Example: Print('Hello Everyone.')
I want output text
Hello Everyone
will highlighted red color.
Thanks you!
An easy way to do this is to import a color module like colorama or termcolor. This site might be useful: Print Colors in Python terminal. For you code it would be:
from colorama import Fore
print(Fore.RED + 'Hello Everyone')
or
import sys
from termcolor import colored, cprint
print(colored('Hello Everyone', 'red')) # method one
cprint('Hello Everyone', 'red') # method two
Try this.
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
print(bcolors.OKGREEN + 'Hello Everyone')