Skip to content
← Back to Community
How do you change text colors and fonts in python?
Profile icon
CreeperBoyKoray

like changing how print statements look like

Answered by 19wintersp [earned 5 cycles]
View Answer
Voters
Profile icon
SamanthaWalsh1
Profile icon
MiguelDe42
Profile icon
ch1ck3n
Profile icon
CreeperBoyKoray
Comments
hotnewtop
Profile icon
19wintersp

The way you can change the colour is through the use of escape codes. Here's a full list of them, though the way you use them is to print it, and then all following text will have that attribute. Alternatively, you can use a library such colored, termcolor or colorama to achieve the same effect automatically.

Profile icon
CreeperBoyKoray

@19wintersp thank you!

Profile icon
Bookie0

Check this out.

This is how to make colors in Python.

Pretty simple, just copy paste these colors (because typing them would be to long...)

# colors black = "\033[0;30m" red = "\033[0;31m" green = "\033[0;32m" yellow = "\033[0;33m" blue = "\033[0;34m" magenta = "\033[0;35m" cyan = "\033[0;36m" white = "\033[0;37m" bright_black = "\033[0;90m" bright_red = "\033[0;91m" bright_green = "\033[0;92m" bright_yellow = "\033[0;93m" bright_blue = "\033[0;94m" bright_magenta = "\033[0;95m" bright_cyan = "\033[0;96m" bright_white = "\033[0;97m"

So to use it, just put the color before the text:

print(bright_yellow + “text here”)