How to print colored text in Python

2 Answers

0 votes
import colorama
from colorama import Fore
from colorama import Style

colorama.init()

print(Fore.GREEN + "Fore.GREEN" + Style.RESET_ALL)
print(Fore.BLUE + Style.DIM + "Fore.BLUE + Style.DIM" + Style.RESET_ALL)
print(Fore.YELLOW + "Fore.YELLOW" + Style.RESET_ALL)
print(Fore.BLUE + Style.BRIGHT + "Fore.BLUE + Style.BRIGHT" + Style.RESET_ALL)



'''
run:

Fore.GREEN
Fore.BLUE + Style.DIM
Fore.YELLOW
Fore.BLUE + Style.BRIGHT

'''

 



answered Apr 10, 2021 by avibootz
0 votes
class ccolors:
    GREEN = '\033[92m' 
    YELLOW = '\033[93m'
    RED = '\033[91m'
    RESET = '\033[0m' 



print(ccolors.GREEN + "ccolors.GREEN" + ccolors.RESET)
print(ccolors.YELLOW + "ccolors.YELLOW" + ccolors.RESET)
print(ccolors.RED + "ccolors.RED" + ccolors.RESET)




'''
run:

ccolors.GREEN
ccolors.YELLOW
ccolors.RED

'''

 



answered Apr 10, 2021 by avibootz

Related questions

1 answer 82 views
1 answer 89 views
89 views asked Jul 18, 2024 by avibootz
1 answer 326 views
1 answer 236 views
...