kandi background
Explore Kits

How to Print Coloured Text in Terminal 

by vigneshchennai74 Updated: Jan 31, 2023

A Python package called "colorama" enables you to print colourful text on the terminal. Both Windows and Linux/Unix systems are compatible with it, and it has the ability to recognise whether it is operating on Windows or not and adapt its behaviour accordingly.  


There are several applications for colourful text printing on terminals, some of which are as follows:  

  • Debugging: You may rapidly find and discover mistakes in your code by printing coloured text, which makes debugging simpler.  
  • Status updates: Updates on the state of your code can be made using coloured text, such as if a task has been successfully completed or if an error has occurred.  
  • User interaction: Using coloured text to make your code output more aesthetically pleasing and approachable can increase user satisfaction and engagement.  
  • Logging: To make log files for debugging, monitoring, and troubleshooting your code simpler to see and analyse, you can use coloured text.  
  • Data visualization: Colored text can be used to visualise data by using color coding, making it easier to comprehend and analyse the information.  
  • CLI tools: Colored text can be used to enhance a command-line tool's user interface.  


Here is how you can print coloured text in Terminal:  

Preview of the output that you will get on running this code in your IDE

Code

In this solution we have used Colorama Library.

  1. Copy this code using "Copy "button above and paste it in your python file IDE
  2. Add Colorama Library to run this code
  3. Run the code to get the texts coloured.


I hope you found this useful i have added the Dependent libraries , versions in the following sections


I have searched using "Print Coloured Text in Terminal" in Kandi. you can try any use case

Environment Tested

I have tested this solution with following versions. Be mindful of changes when working with other versions


  1. This solution is created and executed in Python 3.7.15 version.
  2. This solution is tested on Colorama 0.4.6 version.


Using this solution we able to change the style , color, Brightness of the Text in Terminal using Colorama Library in python with simple steps. This process also facilities an easy to use, hassle free method to create a hands-on working version of code which would help us edit the text in Python.

Dependent Library

coloramaby tartley

Python star image 3043 Version:0.4.6

License: Permissive (BSD-3-Clause)

Simple cross-platform colored terminal text in Python

Support
Quality
Security
License
Reuse

coloramaby tartley

Python star image 3043 Version:0.4.6 License: Permissive (BSD-3-Clause)

Simple cross-platform colored terminal text in Python
Support
Quality
Security
License
Reuse

If you don't have this Colorama Library that required to run this code. You can install by clicking the above link and copying the pip install command from the Colorama page in Kandi. You can search any Library Like colorama in kandi

Support

  1. For any support on kandi solution kits, please use the chat
  2. For further learning resources, visit the Open Weaver Community learning page.

See similar Kits and Libraries

Python
Command Line Interface
Utilities