Introduction: 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!
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: The Codes
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)
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)