How to print colored text in terminal in Python

0 votes

How can I output colored text to the terminal in Python? What is the best Unicode symbol to represent a solid block?

Jun 5, 2020 in Python by kartik
• 37,510 points
2,129 views

1 answer to this question.

0 votes

Hello @kartik,

You can use  Python termcolor module. Usage is pretty simple:

from termcolor import colored

print colored('hello', 'red'), colored('world', 'green')

Or in Python 3:

print(colored('hello', 'red'), colored('world', 'green'))

It may not be sophisticated enough, however, for game programming and the "colored blocks" that you want to do.

Hope it works!!

answered Jun 5, 2020 by Niroj
• 82,720 points

Related Questions In Python

0 votes
1 answer

How to print colored text in Python?

This somewhat depends on what platform you ...READ MORE

answered Dec 17, 2020 in Python by Gitika
• 65,870 points
113 views
+1 vote
2 answers

How to print first character of each word in upper case of a string in Python

class Solution:     def firstAlphabet(self, s):             self.s=s              k=''              k=k+s[0]              for i in range(len(s)):                     if ...READ MORE

answered Oct 28, 2020 in Python by Anurag
7,481 views
+3 votes
2 answers

how to print array integer without [] bracket in python like result = 1,2,3,4,5

Hey @abhijmr.143, you can print array integers ...READ MORE

answered Aug 4, 2018 in Python by Omkar
• 69,130 points

edited Aug 8, 2018 by Omkar 5,737 views
+1 vote
1 answer

How to print an error in Python?

For Python 2.6 and later and Python ...READ MORE

answered Aug 23, 2018 in Python by Priyaj
• 58,120 points
738 views
0 votes
3 answers

Python Selenium best tutorials for beginners

Hope this will help you...Python Tutorial READ MORE

answered Feb 11, 2019 in Python by aldrinjohn
• 140 points
2,404 views
+1 vote
12 answers
0 votes
1 answer

How to find the value of a row in a csv file in python and print column and row of that value ?

Hello @Khanhh , Use panda to find the value of ...READ MORE

answered Oct 15, 2020 in Python by Niroj
• 82,720 points
1,863 views