0
How to color the text output in python3?
I have not learnt how to give color to the text output.
3 Respuestas
+ 3
Really? As far as I know the console based text can't be coloured unless you are on certain IDEs.
+ 1
Not my code. To change the color you need escape codes. Heres an example
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
print( bcolors.WARNING + "Warning! Continue?" + bcolors.ENDC )
Another solution could be this I think (not tried)
from termcolor import colored
print(colored('hello', 'red'), colored('world', 'green'))