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'+'my text'+'\033[95m'
and I got the output without color changed:
[95mmy text[95m
===============================================================================
Then I also tried the package colorama
. The package was installed within cmd
:
python setup.py install
and tried following code in Aptana Studio 3:
from colorama import *
print (Fore.GREEN + 'Green text')
print (Fore.Red + 'Red text')
I got following output:
[32mGreen text
Traceback (most recent call last):
File "C:\Users\My Documents\Aptana Studio 3 Workspace\Practice\test_colorama.py", line 12, in <module>
print (Fore.Red + 'Red text')
AttributeError: 'AnsiCodes' object has no attribute 'Red'
===============================================================================
So now I am really confused. These solutions are upvoted hundreds of times which implies that it should be effective, but in my case it seems not.
May I know how I can print colorful text in the terminal or console?
Many thanks.