

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Print Colors of terminal in Python
In the terminal, if you want to make some texts appears in colored mode, there are numerous ways in python programming to achieve it.
Using python modules
1.termcolor module: It is the ANSII Color formatting for output in the terminal.
import sys from termcolor import colored, cprint text1 = colored('Hello, Tutorialspoint!', 'blue', attrs=['reverse', 'blink']) print(text1) cprint('Hello, Python!', 'blue', 'on_white') print_red_on_blue = lambda x: cprint(x, 'red', 'on_blue') print_red_on_blue('Hello, from Data Science!') print_red_on_blue('Hello, Python!') for i in range(10): cprint(i, 'green', end=' ') cprint("Attention!", 'blue', attrs=['bold'], file=sys.stderr)
Result
- Related Questions & Answers
- How to use rainbow colors in linux terminal
- Sort Colors in Python
- Terminal Control Functions in Python
- Pseudo-terminal Utilities in Python
- Formatted text in Linux Terminal using Python
- Shortest Path with Alternating Colors in Python
- How to install guake drop down terminal terminal on ubuntu
- Defining Colors in CSS3
- The Exposed Terminal Problem
- The Hidden Terminal Problem
- How to open new pseudo-terminal pair using Python?
- How to open a new pseudo-terminal pair using Python?
- How to change colors of a Drawable in Android?
- JavaScript - Complementary Colors Builder
- Java 8 Stream Terminal Operations
Advertisements