an amazing python library to make colored text

Free Python Code - Aug 11 '23 - - Dev Community

welcome everybody 🙂🖐

Today I am going to share with you the best library for text coloring in Python

install colored pip install colored

Now I will make a background for the text
you have 255 color for use

colored.bg(255) The background color will change to white


import colored

print(colored.stylize('This is text to test ', colored.bg(255)))

Enter fullscreen mode Exit fullscreen mode

if you want to change text color use colored.fg(50) in colored.stylize

import colored

print(colored.stylize('This is text to test ', colored.fg(50)))

Enter fullscreen mode Exit fullscreen mode

There is also a great feature in this library
You can control the color of the text and the background together

from colored import Back, Fore, Style

print(f'{Back.RGB(225, 225, 255)}{Fore.red} this is text{Style.reset}')

Enter fullscreen mode Exit fullscreen mode

Back is an class thats containe on amazing functions that help you to set color such as RGB() function and you can choise color
like this Back.white directly
the same feature in Fore class

Now we're done
Don't forget to like and follow 🙂

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .