1def colored(r, g, b, text):
2 return "\033[38;2;{};{};{}m{} \033[38;2;255;255;255m".format(r, g, b, text)
3
4text = 'Hello, World'
5colored_text = colored(255, 0, 0, text)
6print(colored_text)
7
8#or
9
10print(colored(255, 0, 0, 'Hello, World'))
1class bcolors:
2 HEADER = '\033[95m'
3 OKBLUE = '\033[94m'
4 OKGREEN = '\033[92m'
5 WARNING = '\033[93m'
6 FAIL = '\033[91m'
7 ENDC = '\033[0m'
8 BOLD = '\033[1m'
9 UNDERLINE = '\033[4m'
10
11print(f"{bcolors.WARNING}Error : Test message !{bcolors.ENDC}")
1class bcolors:
2 HEADER = '\033[95m'
3 OKBLUE = '\033[94m'
4 OKCYAN = '\033[96m'
5 OKGREEN = '\033[92m'
6 WARNING = '\033[93m'
7 FAIL = '\033[91m'
8 ENDC = '\033[0m'
9 BOLD = '\033[1m'
10 UNDERLINE = '\033[4m'
11
12print(f"{bcolors.WARNING}Warning: No active frommets remain. Continue?{bcolors.ENDC}")
1#pip install termcolor
2from termcolor import cprint
3
4cprint('Hello, World! In yellow highlighted in red!', 'yellow', 'on_red')
5cprint('Hello, World! Underlined in red!', 'red', attrs=["underline"])
1# Python program to print
2# green text with red background
3
4#pip install termcolor
5#pip install colorama
6
7from colorama import init
8from termcolor import colored
9
10init()
11
12print(colored('Hello, World!', 'green', 'on_red'))
1class bcolors:
2 HEADER = '\033[95m'
3 OKBLUE = '\033[94m'
4 OKCYAN = '\033[96m'
5 OKGREEN = '\033[92m'
6 WARNING = '\033[93m'
7 FAIL = '\033[91m'
8 ENDC = '\033[0m'
9 BOLD = '\033[1m'
10 UNDERLINE = '\033[4m'
11