print colored text python on terminal

import colorama
from colorama import Fore, Back, Style
colorama.init(autoreset=True)

print('\033[31m' + 'some red text')
print('\033[39m')  # and reset to default color
print()
print(f"{Fore.RED}C{Fore.GREEN}O{Fore.YELLOW}L{Fore.BLUE}O{Fore.MAGENTA}R{Fore.CYAN}S{Fore.WHITE}!")
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")
print()
print(f"{Back.RED}B{Back.GREEN}A{Back.YELLOW}C{Back.BLUE}K{Back.MAGENTA}G{Back.CYAN}R{Back.WHITE}O{Back.RED}U{Back.GREEN}N{Back.YELLOW}D{Back.BLUE}!")
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")
print()
print(f"{Style.DIM}S{Style.NORMAL}T{Style.BRIGHT}Y{Style.DIM}L{Style.NORMAL}E{Style.BRIGHT}!")
print(f"{Style.DIM}Dim Text")
print(f"{Style.NORMAL}Normal Text")
print(f"{Style.BRIGHT}Bright Text")
print()
print(f"{Fore.YELLOW}{Back.RED}C{Back.GREEN}{Fore.RED}O{Back.YELLOW}{Fore.BLUE}M{Back.BLUE}{Fore.BLACK}B{Back.MAGENTA}{Fore.CYAN}I{Back.CYAN}{Fore.GREEN}N{Back.WHITE}A{Back.RED}T{Back.GREEN}I{Back.YELLOW}O{Back.BLUE}N")
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
'''

4.86
7
A-312 69370 points

                                    def colored(r, g, b, text):
    return "\033[38;2;{};{};{}m{} \033[38;2;255;255;255m".format(r, g, b, text)
  
text = 'Hello, World'
colored_text = colored(255, 0, 0, text)
print(colored_text)

#or

print(colored(255, 0, 0, 'Hello, World'))

4.86 (7 Votes)
0
3
1
Phoenix Logan 186120 points

                                    class colors:
    '''Colors class:
    reset all colors with colors.reset
    two subclasses fg for foreground and bg for background.
    use as colors.subclass.colorname.
    i.e. colors.fg.red or colors.bg.green
    also, the generic bold, disable, underline, reverse, strikethrough,
    and invisible work with the main class
    i.e. colors.bold
    '''
    reset='\033[0m'
    bold='\033[01m'
    disable='\033[02m'
    underline='\033[04m'
    reverse='\033[07m'
    strikethrough='\033[09m'
    invisible='\033[08m'
    class fg:
        black='\033[30m'
        red='\033[31m'
        green='\033[32m'
        orange='\033[33m'
        blue='\033[34m'
        purple='\033[35m'
        cyan='\033[36m'
        lightgrey='\033[37m'
        darkgrey='\033[90m'
        lightred='\033[91m'
        lightgreen='\033[92m'
        yellow='\033[93m'
        lightblue='\033[94m'
        pink='\033[95m'
        lightcyan='\033[96m'
    class bg:
        black='\033[40m'
        red='\033[41m'
        green='\033[42m'
        orange='\033[43m'
        blue='\033[44m'
        purple='\033[45m'
        cyan='\033[46m'
        lightgrey='\033[47m'

3 (1 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
how to copy colored text python print with color on terminal python cahgne colour python terminal python print text in green how to print COLOURED in python print text in different color python python encode colored text print() color python python green color print python print colored string print colored text python 3 python print font color how to change the color of your print python function for colored text python colored console text python red color print python color print text python python color codes to print print orange colour text python python print colored text colorama how to print colors in terminal python how to have terminal be in colour python python colored text on windows python print python code colored python print code with color phow change color in python print python print in command line with red color python color codes print python color print output print stuff different color python colored text python windows print in colours python python print in terminal with colors print colour pytthon tet color in python print how to get coloured text in python how to print words with color on python python color in print can we print text with color in python colored text in print py print colours in python how to make a print colored in python print colored python how to change text colored in python 3 print colored text python pip python terminal output color python print text in color in terminal how to print color changing text in python python give color to terminal output terminal print color in python interactive python print color text in cmd python print output color python terminal change color of print text python print command color Color Text terminal Python Coloured Terminal Text python python print different color python colored string python print in colors python get text to original color of terminal how to print python with color python change output text color how to print with color python html color python print python print color text and background in terminal python print with color red python print text with background color python print colors in terminal python how to print in color python colored shell tekst python all text in color python write colored text slowly How to use color in print python python print to terminal in colour change color in python print python print statement color python terminal color text color code values in python print python color text output print() with color python python colored print output color in print statement python how to print colored text in python on windows python colored prints python program change print color how to display colored text in python python how to print a colored message python print colored text to terminal without colorama python text color green from terminal python colored text output how to change color print in python python print colored text with format python3 print colored text with format make output colored python make print output colored python add color to print statements python terminal how print in red color in python python coloured print python colored oconsole text how to color a print in python python colored text in terminal colored string python python 3 print in color print colored text python jupyter python print colored text on windows print colour python print in red color python color terminal print python print color text python python3 print colored text python extract colored text how to make text colored in command prompt python print python different color output colored using python python print color cmd python output color change color of print python colored terminal output python print terminal python color How to change color of text in terminal python change console text color python windows colored terminal Python python tkinter print colored text python print colored text windows Python fancy console output how to print in color in python python color text terminal How to print color text to command prompt python print in colour python python change color on print print on terminal with different color python pyton terminal print with colors how to print in colors inconsole with python python print colour colored print text python how to do colored printing in python colored output in python how to make python print stuff with color set string color in python terminal python color terminal text how to print colored text in terminal in python python write colored text python change terminal text color python how to output a color python print color text terminal color print python printing coloured texts python how to change python print colour python coloured terminal outpyt print with colors terminal python change color phue python python print green letters python how to print different color python terminal cmd color text python cli colored text python print change color color print python linux terminal python how to print with color python color output terminal python in terminal print with color print coloured text to terminal python how to print colored text in command line windows python3 print with colour python python colored terminal python console colored text colores print python terminal text color python python print terminal colors python colored console text color in terminal python python print displays color code but not colored text how to print color with python output print something in a color python print python set color set color print python colored print python how to print red colour text python colors python print color text python terminal python colored python print string in color print colour text in python how to print in color python how to print colored text in python termcolor colour words in python terminal how to print color text in python 3 python color print text output color python color print in python python 2.7 print colored text python 2.7 print color python2.7 print color python print standard output colored python print in different color on terminal python colored str print color in terminal python how to print color on python print text with color in python how to print color python python print color text terminal python font color change print print red color python python color print statements python output colored text how to print in colors in python python print whit color python print text in color how to use color in console python print text in color python python how to print colored text print on python with colors python set terminal color pandas how to colorize numbers in "terminal" print color coding python' print text differetn colors python colored prints python colored text python doesn't work print specific letter in color how to print out multicolored text in python python print different colors how to stop color on print in python how make color text in python custom color text python how to add font color in python reset color ascii code python python console text color pyhton print colors python colors format python add coloured text to console how to print color things in python console colors strings red python python rgb text python change color in terminal coloring stdout in python best python console color python print in color to terminal print colored with bg coclor python python pront color how to color code in python python colord yex pycharm print red text pycharm print in red python console color codes python print color in terminal python print in red color print color on screen python python how to color text coloring print methods python colorize terminal print color code python print python print reset console color python how to print value to terminal cool pythonw how to print value to treminal cool console color python how to print purple in python console display colored text python print another color python different colors print python print text with color coloured text on terminal using py colors print python printing in colors in python color python output print string red color python print with color part of string how to acces colors in a string python putting colores into string in phyton how to print in colors python PYTHON TERMINAL COLOR FADE how to print lines with different color in python print color in terminal make colored text python how to print text with color in python how to print text in color python how to print colored text in python rgb python console quiz code with color python print colored text 3.9 py print color print colored text in python with backslash escapes python print green blue text how to add color to python text print rainbow text python console python print out colours in console how to print different colors in python how to make text in python a color print a color in python python change print text color How to output a coloured string in Python fmro termcolor import colored python color terminal change color print python green text oython python print colored doesn't work how to change the color of print text in python get colours supported by python print python text colour color of string python print red on cmd python colored text python console get terminal supported colours python how to print colored text python print a blue box in python how to print rgb text to terminal python colorized text print colored text python on terminal red color in print statement python how to make python change color print colored text in python not working python print in color not working python console output not in color how to Add Colour to Text in Python for a single print how to print colors in python python print a colored string print colored text to console python python style console output print text in green cmd python colorf scheme python print to terminal with color python print red error message what colors can i write as a string python red TERMINAL color python text color in python how to print colored background to console python how to print colored text to console python how to color output in python python output prints colors colour priint in python adding colored text and normal text in python print color in python output change text color python how to use colors in text python how to print colored messages in terminal can you write a text with diffrent colors in pygame color in python console python colors class how to print color with html codes in python string color python how to color text python color text python with escape characters colorful printing python python print colors python print color unixterminal color python print color unix print colorpython font colors python python coloured text how to color output text in python How to put colours on output python how to change output color in python how to add color to print in python python print colored code print in colors colored python output color a character in python color print python python color printing how to input colored text in python add color to print python python command line color color text during execution time in python coloured text during execution time in python how to do colored text in python how to change color of print in python python prinyt in red how to print different color code print cool fonts in python terminal python print color text with ansi print colored font print with color python how to rpitn something in yellow in python print different colors python add color in python example Add color in python python colored text in console colored text python how to color in python how to change color in print python python colored print python print colors based on number color python string colored python format pip package print in color text color python text colour python python print farbe display word in stylein terminal python python print colored text terminal python terminal bright colors python command line text color python color print string to command line' how to change the output color in python python format print statemet with colors output colors on python terminal python color format 30 to 37 command line colors python python colur in output python print message color how to print orange in python how to code the color of your text in python colored stdout in python colour in python string python how to get a color can I color print statements in python white colored text python python only certain part of output colored def colored(r g b text ) python different color text python output colored text according to input python output colored text according to input python3 how to make red text in python how to print colored strings in python for windowa how to print color in python how to print color text in python in loop open and close color string in python set colour in python strinf color outputer python console modules green text python python coloured string python giving master a color colored text python w2schools print color to terminal print with color python 3 how to change the output text color python python coloured text output python unicode color terminal colours python how to print a color block in python color strings python window how to color print python python output highlight text that is typed change the text color in python how can I print a red text in command line using python string prompt colours pythn HOW to write in colors on python blue text in colored python library print colourful big character in python color codes python stack overflow color codes python stackoverflow python cli colors use colors for print python highlight text as it is typed python print python change color of terminal how to highlight print in python how to print green and red text in python python color cmd how to change terminal color using python how to print to color python terminal string format color codes python python string color print entire console in color python colorize python output python add color to string text print ouput in color pythin change print color python terminal colors python print highlight change the coloer of print in pythong python ASCI colors on output print text red python python change string color how do you do coloured text in python how to print with colors python print colors python how to use colors in python run consolw coloured text showing up as numbers in python oloured text not showing up in py file color text in terminal python how tom make text have colour in python python print colored text how to change print color in python output color ed text python print colored output python how to output colour terminal python python print ascii color python print colored coloured text in python python change all console color add color to printed python message colores python text python print color text on "linux" python print color text on linux how to color text in python 3 terminal colors python how to print the active text in python change terminal color python python print color to cmd python print red error python change foreground color output text color python print python console coloured text how to print a color in python red print python2 red print python print not changing color python color text python python print colored output console print color text in python python print color format how to print in colour on python python color for tetx how to use colors in python font color python on terminal print colored erroe windows doesn't understand ascii color print in python how to change the colour of one output word in python python set console color ansi coloring output python change color output python how to get colour print out in python all python color codes stackoverflow python color codes terminal how to add color to code python stack overflow how to add color to code python stackoverflow python colour print terminal coloured text python python print error in red python print red terminal print colored text python display green text python red color python print custom color in terminal python color text console how to make python terminal colorful how to print with colors in python how to print in error font python python print error in color print coloured text in python color terminal python how do i print something in color python python terminal text color pythonm cahnge string colort how to change python text color color in python terminal python display color how to color text in python python colored terminal output Display coloured text python python print in red python console color colored output python terminal color python color in the python console sample way to change color in python on terminal python terminal color how to change python terminal text color how to print highlighted text in python python print color module how to print with color in python class color python how to change print colour python color output in python python print colours inconsole python red text python change color of print print in red python how to print color text in python pirnt color python ascii text file color python color text in python print an error message python in red best color format for python shell python how to add color python telnet colors how to use color in python python consol color printing how to highlight a part of a text in python cmd python change font color python change color of print text python colored console text mac python all terminal colors add color python terminal change color python terminal how to highlight a string in python using sys python print color terminal set text color example python print colored text in python python text color python edit color of already printed text python change color of already printed text python color text python coloured colourful python terminal how to get colored text in python print red text python colored text in python python color terminal python change print color print color in python how get sequence of ascii colors in python change print color python using colors in python python print string in red color print in color in python how to change color of terminal text in python 3 coloured text in command line python python color in terminal python command line table colors display colors from string python python print with color print in green python python cli color python colors print color output python python print with colors color python console making color text in python in linux python color print how to make colored text in python python colored output python colored console output how to colorize the print output python printy python colors how to make python code show up red python how to print coloured text display color while print python print in color python colour text python How to use coloured text in python print color python how to change color of text in python how to make text different color python python ascii change color codes python smtpib ascii change color codes python ascii change color codes colour python text python print in color apply color to text python python print color python console colors python colorful print how to stop color in python colors in terminal python python change color of text python colored text print unicode color characters in python print unicode color characters how to print colored text in python how to color print in python print colors to terminal python how to make colored words in python print red python font colors in python python windows cmd rgb text how to make add color in text in python change textt color in python how to make text light green in python python add color to print python print color output print python color can you change the output font color in python ascii color codes python print colored text python
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source