Printing Colored Text in Python Without Any Module
by Megacapacitor in Circuits > Software
59868 Views, 0 Favorites, 0 Comments
Printing Colored Text in Python Without Any Module
After my second Instructable was deleted accidentally, I decided to make a new one.
In this one I will show you how to print colored text in python!
The Codes
Try:
TGREEN = '\033[32m' # Green Text print (TGREEN + "This is some green text!")
We see that after the green text is printed, the whole shell changes color!
To combat that can we use this?
TWHITE = '\033[37m' print (TGREEN + "It doens't reset!" , TWHITE)
NO!!
It turns all the text white...and a different type of 'dull' white if you see it carefully.
If you want to commit your code to GITHUB, then many people using your code may have a customized Python Shell with probably YELLOW or Something as their text/background color!
So the answer is:
ENDC = '\033[m' # reset to the defaults print (TGREEN + "Das ist es!" , ENDC)