python ansi colors code example
Example 1: ansi colors
Black \e[0;30m
Blue \e[0;34m
Green \e[0;32m
Cyan \e[0;36m
Red \e[0;31m
Purple \e[0;35m
Brown \e[0;33m
Gray \e[0;37m
Dark Gray \e[1;30m
Light Blue \e[1;34m
Light Green \e[1;32m
Light Cyan \e[1;36m
Light Red \e[1;31m
Light Purple \e[1;35m
Yellow \e[1;33m
White \e[1;37m
Example 2: python ansi escape sequences color collection
class colors:
reset = "\033[0m"
# Black
fgBlack = "\033[30m"
fgBrightBlack = "\033[30;1m"
bgBlack = "\033[40m"
bgBrightBlack = "\033[40;1m"
# Red
fgRed = "\033[31m"
fgBrightRed = "\033[31;1m"
bgRed = "\033[41m"
bgBrightRed = "\033[41;1m"
# Green
fgGreen = "\033[32m"
fgBrightGreen = "\033[32;1m"
bgGreen = "\033[42m"
bgBrightGreen = "\033[42;1m"
# Yellow
fgYellow = "\033[33m"
fgBrightYellow = "\033[33;1m"
bgYellow = "\033[43m"
bgBrightYellow = "\033[43;1m"
# Blue
fgBlue = "\033[34m"
fgBrightBlue = "\033[34;1m"
bgBlue = "\033[44m"
bgBrightBlue = "\033[44;1m"
# Magenta
fgMagenta = "\033[35m"
fgBrightMagenta = "\033[35;1m"
bgMagenta = "\033[45m"
bgBrightMagenta = "\033[45;1m"
# Cyan
fgCyan = "\033[36m"
fgBrightCyan = "\033[36;1m"
bgCyan = "\033[46m"
bgBrightCyan = "\033[46;1m"
# White
fgWhite = "\033[37m"
fgBrightWhite = "\033[37;1m"
bgWhite = "\033[47m"
bgBrightWhite = "\033[47;1m"
Example 3: python colors code
print("\033[0;37;40m Normal text\n")
print("\033[2;37;40m Underlined text\033[0;37;40m \n")
print("\033[1;37;40m Bright Colour\033[0;37;40m \n")
print("\033[3;37;40m Negative Colour\033[0;37;40m \n")
print("\033[5;37;40m Negative Colour\033[0;37;40m\n")
print("\033[1;37;40m \033[2;37:40m TextColour BlackBackground TextColour GreyBackground WhiteText ColouredBackground\033[0;37;40m\n")
print("\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")
print("\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")
print("\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")
print("\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")
print("\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")
print("\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")
print("\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")
print("\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")
\n")