# the string '33[92m' represents the color green,# and '33[0m' is used to go back to the standard color of the terminal
GREEN ='33[92m'
END_COLOR ='33[0m'print(GREEN +"Hello World"+ END_COLOR)
from colorama import init
from colorama import Fore
init()print(Fore.BLUE +'Hello')print(Fore.RED +'Hello')print(Fore.YELLOW +'Hello')print(Fore.GREEN +'Hello')print(Fore.WHITE +'Hello')#test in vscode#code by fawlid
#exampleprint("33[1;31mHello World!33[0m")print("33[<properties>;<color>m")
Black 30 No effect 0 Black 40
Red 31 Bold 1 Red 41
Green 32 Underline 2 Green 42
Yellow 33 Negative1 3 Yellow 43
Blue 34 Negative2 5 Blue 44
Purple 35 Purple 45
Cyan 36 Cyan 46
White 37 White 47
# Python program to print # green text with red background #pip install termcolor#pip install coloramafrom colorama import init
from termcolor import colored
init()print(colored('Hello, World!','green','on_red'))
"""
Let’s start by installing the library:
$ pip install colorama
CHANGING COLOR
We can start by changing the color of the text.
Colorama allows you to use eight different colors:
black, red, green, yellow, blue, magenta, cyan, white.
They are implemented as variables in the Fore class.
Their name is the name of the color, written all upper case
"""from colorama import Fore, init
init()print('Now is not colored')print(Fore.RED +'some red text')print(Fore.GREEN +'some green text')print(Fore.MAGENTA +'some magenta text')print(Fore.RESET +'Back to normal')"""
CHANGING BACKGROUND
The next class we will see is Back .
This implements the same keyword as the Fore class:
BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET.
However in this case the color will be used to change the background of the string
(i.e. to highlight the text)
"""from colorama import Back, init
init()print('Now is not highlighted')print(Back.RED +'some red background')print(Back.GREEN +'some green background')print(Back.MAGENTA +'some magenta background')print(Back.RESET +'Back to normal')"""
CHAANGING BRIGHTNESS
we can use the Style class to change the brightness of the output.
There are three keywords in this class:
BRIGHT make the text bright;
DIM make the text dim (although it looks the same as normal text);
NORMAL to have the normal brightness.
"""from colorama import Style, init
init()print('Normal text')print(Style.BRIGHT +'Bright text')print(Style.NORMAL +'Normal text')# this class also implements the RESET_ALL keyword,# which is used to reset everything (brightness, color, background) to their normal valuesfrom colorama import Fore, Back, Style, init
init()print(Style.BRIGHT +'Now the text is bright')print(Fore.RED +'Now the text is bright and red')print(Back.GREEN +'Now the text is bright, red and with green background')print(Style.RESET_ALL +'Now everything is back to normal')
# Python program to print# green text with red backgroundfrom colorama import init
from termcolor import colored
init()print(colored('Hello, World!','green','on_red'))
# python -m pip install CrafterColortry:from CrafterColor.Print import printColors
from CrafterColor.Print importprintexcept ModuleNotFoundError:import os
os.system("python -m pip install CrafterColor")print("rerun the program")
exit(-1)# the a available keywards Colorsfor LOF in printColors:print("Hello, World",LOF,sep=": ",color=LOF)