The standard command to color the output of print
in Python 3 using ANSI escape codes seems not to be functioning.
It has to do with the changes that accompany the newest versions of Python 3, I believe.
My System: Python 3.7.3, Windows 10, IDLE.
Although it works fine on Python 2.7
, with Python 3.7
it simply doesn't function.
print("\033[1;32;40m Bright Green \n")
in IDLE as shown in this article outputs[1;32;40m Bright Green
. On the contrary this works fine on an onlinePython 2
parser giving a colored background.A correction was found that on
Python 3
the escape character is\x1b
instead of\033
. A modified expression inside theprint
statement such asprint("\x1b[1;32;40m Bright Green \n")
in IDLE outputs[1;32;40m Bright Green
and no colored background.- Running
print("\033[1;32;40m Bright Green \n")
on apy
file still outputs[31;1;4mHello[0m
- Since there are differences between my local system I tried to run on an online
Python 3
parserprint("\033[1;32;40m Bright Green \n")
and it gave me[1;32;40m Bright Green
.
This use of ANSI escape codes is mostly offered as a solution in links.
What do I do wrong?