Search This Blog

Monday, November 28, 2011

Python colors on command line print

While writing a command line script, adding colors might ease understanding the output. To print a line in color just follow this simple technique
print '\033[91m' + 'my error string' + '\033[0m'
You might have guessed it by now. '\033[' is a control char and '0m'/ '91m' define the color to be displayed.
Few examples: 0m is white 91m red 92m green 93m orange 94m blue Hope this helps

No comments: