Colour of output text

Tim Harig usernet at ilthio.net
Thu Jul 9 13:53:12 EDT 2009


On 2009-07-09, Alex Rosslyn <black.linen99 at gmail.com> wrote:
> I would like to learn a way of changing the colour of a particular
> part of the output text. I've tried the following

http://catb.org/esr/faqs/smart-questions.html

> import os
> os.system("color 17")
> print "This should be white on blue"

I assume that you are on Windows?

> But that command changes the colour of ALL the text and the whole
> background. What i'm trying to do is simple: Change a single part (A
> letter, a word, a phrase) of the output text.

If you are on Windows, then there is an API accessing the Windows Console:

http://msdn.microsoft.com/en-us/library/ms682010(VS.85).aspx

On Unix operating systems this would be done through the curses interface:

http://docs.python.org/library/curses.html



More information about the Python-list mailing list