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}")
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'))
1print("\033[0;37;40m Normal text\n")
2print("\033[2;37;40m Underlined text\033[0;37;40m \n")
3print("\033[1;37;40m Bright Colour\033[0;37;40m \n")
4print("\033[3;37;40m Negative Colour\033[0;37;40m \n")
5print("\033[5;37;40m Negative Colour\033[0;37;40m\n")
6
7print("\033[1;37;40m \033[2;37:40m TextColour BlackBackground TextColour GreyBackground WhiteText ColouredBackground\033[0;37;40m\n")
8print("\033[1;30;40m Dark Gray \033[0m 1;30;40m \033[0;30;47m Black \033[0m 0;30;47m \033[0;37;41m Black \033[0m 0;37;41m")
9print("\033[1;31;40m Bright Red \033[0m 1;31;40m \033[0;31;47m Red \033[0m 0;31;47m \033[0;37;42m Black \033[0m 0;37;42m")
10print("\033[1;32;40m Bright Green \033[0m 1;32;40m \033[0;32;47m Green \033[0m 0;32;47m \033[0;37;43m Black \033[0m 0;37;43m")
11print("\033[1;33;40m Yellow \033[0m 1;33;40m \033[0;33;47m Brown \033[0m 0;33;47m \033[0;37;44m Black \033[0m 0;37;44m")
12print("\033[1;34;40m Bright Blue \033[0m 1;34;40m \033[0;34;47m Blue \033[0m 0;34;47m \033[0;37;45m Black \033[0m 0;37;45m")
13print("\033[1;35;40m Bright Magenta \033[0m 1;35;40m \033[0;35;47m Magenta \033[0m 0;35;47m \033[0;37;46m Black \033[0m 0;37;46m")
14print("\033[1;36;40m Bright Cyan \033[0m 1;36;40m \033[0;36;47m Cyan \033[0m 0;36;47m \033[0;37;47m Black \033[0m 0;37;47m")
15print("\033[1;37;40m White \033[0m 1;37;40m \033[0;37;40m Light Grey \033[0m 0;37;40m \033[0;37;48m Black \033[0m 0;37;48m")
16
17\n")
18
1print(f"{bcolors.WARNING}Warning: No active frommets remain. Continue?{bcolors.ENDC}")