Print output method with color special effects

 

Written form

\ 033 [ Display mode ; font color ; background color m string \ 033 [0m    // Italic underline is variable part, red is fixed

 

Display mode : 0 (default), 1 (highlighted), 22 (non-bold), 4 (underlined), 24 (non-underlined), 5 (flickered), 25 (non-flickered), 7 (inverted), 27 (non-inverted display)

 

Font color : 30 (black), 31 (red), 32 (green), 33 (yellow), 34 (blue), 35 (pink), 36 (cyan), 37 (white)

 

Background colors : 40 (black), 41 (red), 42 (green), 43 (yellow), 44 (blue), 45 (pink), 46 (cyan), 47 (white)

 

Example :

# Pink font, brightness, no background color 
Print ( ' \ 033 [. 1; 35m Hello Word \ 033 [0m ' )    

# white font, no bright red background 
Print ( ' \ 033 [0; 37 [; 41M Hello Word \ 033 [0m ' )

Results show:

 

Guess you like

Origin www.cnblogs.com/chunqiu666/p/12750520.html