Reprint to http://www.cnblogs.com/yinjia/
In the development of the project, in order to facilitate debugging code, often to stdout output some logs, the default of these logs are directly displayed in the terminal. And the general application server, third-party libraries, and even some of the server's announcements are also displayed in the terminal, which disturbs the information we want.
The writing format, and the related instructions are as follows:
1 Format: \033[display mode; foreground color; background colour m23Description4Foreground background color5---------------------------------------6 30 40Black7 31 41Red8 32 42Green9 33 43Yellow color10 34 44Blue11 35 45Purplish red12 36 46Cyan Blue13 37 47 white 14 show way meaning 15-------------------------16 17 1 highlight 18 4 use underline Span style= "color: #008080;" >19 5 blinking 20 7 anti-white display 21 8 invisible 22 23 example: 24 \033[1;31;40m <!--1-highlight 31-foreground color Red 40-background black-- 25 \033[0m <!--with the terminal default setting, which cancels the color setting-->
Example:
1Print‘\033[1;31;40m‘)2Print‘*' * 50)3Print‘*host:\t', 2002)4Print‘*uri:\t‘,‘http://127.0.0.1‘)5Print ' *args:\t) 6 *time:\t ", 22:28< Span style= "color: #800000;" > ' ' 7 print ( '
Operation Result:
Description: http://127.0.0.1 white display is wrong!!!
Python_ console Output Color-colored text method