B
B
beduin012015-03-13 15:36:59
Python
beduin01, 2015-03-13 15:36:59

Python 2.4 colorize console without 3rd party modules?

There is a very old server on Solaris. Python 2.4. There is no Internet access. I can't install any modules.
How can I highlight certain text with color? It means from Python to print some text on the screen in different colors.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yuri Shikanov, 2015-03-13
@dizballanze

here are the color codes:

Black        0;30     Dark Gray     1;30
Blue         0;34     Light Blue    1;34
Green        0;32     Light Green   1;32
Cyan         0;36     Light Cyan    1;36
Red          0;31     Light Red     1;31
Purple       0;35     Light Purple  1;35
Brown/Orange 0;33     Yellow        1;33
Light Gray   0;37     White         1;37

In Python you do this:
print '\033[0;31mHello Red!'
print '\033[0;32mHello Green!'

e1322e1edd1340029ab917c7ca74d52c.png

V
Vladimir Martyanov, 2015-03-13
@vilgeforce

ANSI color codes look. They will probably work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question