Answers for "color in python"

1

color text in python

'''
Install colorama by typing this in the terminal:
python -m pip install colorama
'''

# Importing Colorama
import colorama
from colorama import Fore
from colorama import Back
from colorama import Style

# Initialising Colorama (Important)
colorama.init(autoreset=True)

# Colored Text
print(f"{Fore.RED}Red Text")
print(f"{Fore.GREEN}Green Text")
print(f"{Fore.YELLOW}Yellow Text")
print(f"{Fore.BLUE}Blue Text")
print(f"{Fore.MAGENTA}Magenta Text")
print(f"{Fore.CYAN}Cyan Text")
print(f"{Fore.WHITE}White Text")

# Backgrounds
print(f"{Back.RED}Red Background")
print(f"{Back.GREEN}Green Background")
print(f"{Back.YELLOW}Yellow Background")
print(f"{Back.BLUE}Blue Background")
print(f"{Back.MAGENTA}Magenta Background")
print(f"{Back.CYAN}Cyan Background")
print(f"{Back.WHITE}White Background")

# Styles
print(f"{Style.DIM}Dim Text")
print(f"{Style.NORMAL}Normal Text")
print(f"{Style.BRIGHT}Bright Text")

# Combining Colored Text, Backgrounds and Styles 
print(f"{Fore.GREEN}{Back.YELLOW}{Style.BRIGHT}Green Text - Yellow Background - Bright")
print(f"{Fore.CYAN}{Back.WHITE}{Style.DIM}Cyan Text - White Background - Dim")


'''
Fore: BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET.
Back: BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET.
Style: DIM, NORMAL, BRIGHT, RESET_ALL
'''
Posted by: Guest on October-27-2021
3

simple colours python

pip install simple-colors

from simple_colors import *

print(green('hello'))
print(green('hello', 'bold'))
print(green('hello', ['bold', 'underlined']))
Posted by: Guest on March-30-2020
3

python color

from colorama import init, Fore, Back, Style
init()

print("normal")
print(Fore.LIGHTYELLOW + "yellow" + Fore.RESET)
print(Back.RED + "red" + Back.RESET)
print(Fore.YELLOW + Back.RED + "both" + Style.RESET_ALL)
print("normal again")



The possible colors are: BLACK, BLUE, CYAN, GREEN, LIGHTBLACK_EX, 
 LIGHTBLUE_EX, LIGHTCYAN_EX, LIGHTGREEN_EX, LIGHTMAGENTA_EX, LIGHTRED_EX, 
 LIGHTWHITE_EX, LIGHTYELLOW_EX, MAGENTA, RED, WHITE, YELLOW
Posted by: Guest on February-22-2021
3

python colors code

print("33[0;37;40m Normal textn")
print("33[2;37;40m Underlined text33[0;37;40m n")
print("33[1;37;40m Bright Colour33[0;37;40m n")
print("33[3;37;40m Negative Colour33[0;37;40m n")
print("33[5;37;40m Negative Colour33[0;37;40mn")
 
print("33[1;37;40m 33[2;37:40m TextColour BlackBackground          TextColour GreyBackground                WhiteText ColouredBackground33[0;37;40mn")
print("33[1;30;40m Dark Gray      33[0m 1;30;40m            33[0;30;47m Black      33[0m 0;30;47m               33[0;37;41m Black      33[0m 0;37;41m")
print("33[1;31;40m Bright Red     33[0m 1;31;40m            33[0;31;47m Red        33[0m 0;31;47m               33[0;37;42m Black      33[0m 0;37;42m")
print("33[1;32;40m Bright Green   33[0m 1;32;40m            33[0;32;47m Green      33[0m 0;32;47m               33[0;37;43m Black      33[0m 0;37;43m")
print("33[1;33;40m Yellow         33[0m 1;33;40m            33[0;33;47m Brown      33[0m 0;33;47m               33[0;37;44m Black      33[0m 0;37;44m")
print("33[1;34;40m Bright Blue    33[0m 1;34;40m            33[0;34;47m Blue       33[0m 0;34;47m               33[0;37;45m Black      33[0m 0;37;45m")
print("33[1;35;40m Bright Magenta 33[0m 1;35;40m            33[0;35;47m Magenta    33[0m 0;35;47m               33[0;37;46m Black      33[0m 0;37;46m")
print("33[1;36;40m Bright Cyan    33[0m 1;36;40m            33[0;36;47m Cyan       33[0m 0;36;47m               33[0;37;47m Black      33[0m 0;37;47m")
print("33[1;37;40m White          33[0m 1;37;40m            33[0;37;40m Light Grey 33[0m 0;37;40m               33[0;37;48m Black      33[0m 0;37;48m")
 
n")
Posted by: Guest on December-17-2020
1

python colours

const (
    ResetAll = "33[0m"

    Bold       = "33[1m"
    Dim        = "33[2m"
    Underlined = "33[4m"
    Blink      = "33[5m"
    Reverse    = "33[7m"
    Hidden     = "33[8m"

    ResetBold       = "33[21m"
    ResetDim        = "33[22m"
    ResetUnderlined = "33[24m"
    ResetBlink      = "33[25m"
    ResetReverse    = "33[27m"
    ResetHidden     = "33[28m"

    Default      = "33[39m"
    Black        = "33[30m"
    Red          = "33[31m"
    Green        = "33[32m"
    Yellow       = "33[33m"
    Blue         = "33[34m"
    Magenta      = "33[35m"
    Cyan         = "33[36m"
    LightGray    = "33[37m"
    DarkGray     = "33[90m"
    LightRed     = "33[91m"
    LightGreen   = "33[92m"
    LightYellow  = "33[93m"
    LightBlue    = "33[94m"
    LightMagenta = "33[95m"
    LightCyan    = "33[96m"
    White        = "33[97m"

    BackgroundDefault      = "33[49m"
    BackgroundBlack        = "33[40m"
    BackgroundRed          = "33[41m"
    BackgroundGreen        = "33[42m"
    BackgroundYellow       = "33[43m"
    BackgroundBlue         = "33[44m"
    BackgroundMagenta      = "33[45m"
    BackgroundCyan         = "33[46m"
    BackgroundLightGray    = "33[47m"
    BackgroundDarkGray     = "33[100m"
    BackgroundLightRed     = "33[101m"
    BackgroundLightGreen   = "33[102m"
    BackgroundLightYellow  = "33[103m"
    BackgroundLightBlue    = "33[104m"
    BackgroundLightMagenta = "33[105m"
    BackgroundLightCyan    = "33[106m"
    BackgroundWhite        = "33[107m"
)
Posted by: Guest on October-21-2020
0

color plt

matplotlib. colors
b : blue.
g : green.
r : red.
c : cyan.
m : magenta.
y : yellow.
k : black.
w : white.
Posted by: Guest on November-06-2020

Python Answers by Framework

Browse Popular Code Answers by Language