Friday 12 June 2020

Python printing colourful text


Pythons scripts running on terminal can make use of Terminal colours to enhance output.



Using Combination of Foreground and Backgrunod can ensure required colours.
\033[1;41m \033[97m{} \033[00m"

The way I manage is by defining function and call with required text. Or you could define it in your own class and include

Text FormatForeground (text) colorBackground color
0: normal text30: Black40: Black
1: bold31: Red41: Red
4: Underlined text32: Green42: Green
33: Yellow43: Yellow
34: Blue44: Blue
35: Purple45: Purple
36: Cyan46: Cyan
37: White47: White