We know that at the command line, Python's output has the same string color as the normal character.
If we want to emphasize certain characters, we can make use of the part of the code that will be emphasized to become a color.
The Linux Terminal command can display a color that cannot be displayed under the Windows CMD Terminal display
The writing format, and the related instructions are as follows
Format: \033[display mode; background color m (all content) format: \033[display; foreground color m emphasize content \033[0m (some content) Description: foreground background color ---------------------- -----------------, black, red, green, yellow, Blue 45 The significance-------------------------0 The terminal default setting 1 highlight 4, purple red use underscore 5 blinking 7 anti-white display 8 invisible \033[0m #采用终端默认设置
Gca
1 Print("\033[1;32m This is a test \033[0m")#1 Highlight 32 foreground green2 Print("\033[1;42m This is a test \033[0m")#42 background Color green3 Print("\033[1;31;40m; This is a test \n123456")#1 Highlight 31 Red 41 black background4 Print("\033[4;31m This is a test \033[0m\n123")#a section of content 4 underline
Python's color display