Skip to content Skip to sidebar Skip to footer

How To Print Colorful Text In Python Terminal?

I know this question have been raised at Stackoverflow here So I've tried the following code from joeld's answer. Here is the code in IDLE (I am using Python 2.7): print '\033[95m'

Solution 1:

There's no Red

>>> import colorama
>>> colorama.Fore.Red
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'AnsiCodes'object has no attribute 'Red'

But, RED exists:

>>> colorama.Fore.RED
'\x1b[31m'

Solution 2:

IDLE is not a proper shell. Do this from a Python session in a normal terminal.

Post a Comment for "How To Print Colorful Text In Python Terminal?"