In order to make the output more beautiful and eye-catching, sometimes you need to add some color to the Python output characters, very simple to share the following method:
Format: \033[display mode; foreground color; background colour m
Foreground background color
---------------------------------------
30 40 Black
31 41 Red
32 42 Green
33 43 Yellow
34 44 Blue
35 45 Purplish red
36 46 Cyan Blue
37 47 White
Meaning of display mode
-------------------------
0 Terminal default settings
1 highlighting
4 using underscores
5 Flashing
7 Anti-white display
8 Not visible
#linux终端中的颜色是用转义序列控制的, the escape sequence starts with the ESC and can do the same with \033 (the ASCII code for ESC is 27 in decimal notation, which equals 33 in octal).
..........................................................
#!/usr/bin/ev python
Print "\033[31m.\033[0m" * 30
Print "\033[1;33;44m"
Print "AAAAAAAAAAAAAAAAAAAAAA"
Print "BBBBBBBBBBBBBBBBBBBBBB"
Print "\033[0m"
Print "\033[31m.\033[0m" * 30
..........................................................
Effect
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/77/0B/wKioL1ZhYaywOxpmAAApgGQHhdE524.png "title=" 1.png " alt= "Wkiol1zhyaywoxpmaaapggqhhde524.png"/>
This article is from the "Rookie Growth Road" blog, please be sure to keep this source http://francis905.blog.51cto.com/3048056/1719673
Python output with color text in Linux