DEV Community

Hamza Hesham
Hamza Hesham

Posted on

5 2

Print coloured text in python

Hello,Today we will print coloured text in python.
First, we will install ansi-colours moudle.

pip install ansi-colours

After installing we will import ansi-colours as colour
then print your sentence after choosing the color.

from ansi_colours import AnsiColours as colour
print(colour.red('Follow') + colour.blue('ME!'))
Enter fullscreen mode Exit fullscreen mode

Alt Text
Buy Me A Coffee
twitter:https://twitter.com/Oxy_oxide
buy me a coffee : https://www.buymeacoffee.com/Oxyoxide
Don't forget to follow me.
Thanks for reading.

Top comments (2)

Collapse
 
artis3n profile image
Ari Kalfus

colored is a nice library for colorized text as well

Collapse
 
delta456 profile image
Swastik Baranwal

Nice post but colorama is better than this one.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, cherished by the supportive DEV Community. Coders of every background are encouraged to bring their perspectives and bolster our collective wisdom.

A sincere “thank you” often brightens someone’s day—share yours in the comments below!

On DEV, the act of sharing knowledge eases our journey and forges stronger community ties. Found value in this? A quick thank-you to the author can make a world of difference.

Okay