Home >Backend Development >Python Tutorial >How to set python color
When a friend is doing Python, he doesn’t know how to set the color. let me tell you! The character color of the Python terminal is controlled by escape sequences. It is a system display function in text mode and has nothing to do with the specific language.
The escape sequence starts with ESC, which is completed with \033 (the ASCII code of ESC is 27 in decimal and 033 in octal).
Grammar format:
Format: \033[Display mode; foreground color; background color m
Note: Since the values representing the different meanings of the three parameters are all unique There are no duplicates, so there is no fixed requirement for the writing order of the three parameters, and the system can recognize them; however, it is recommended to follow the default format
Parameter meaning:
Display mode Meaning
0 terminal default settings
1 Highlight display
4 Use the next line
## 5 Flash## 7 Anti -White Display
## 8 8 InvisibleForeground Color Background Color Color
30 40 Black
31 41 Red
33 43 Yellow34 44 Blue White
The above is the detailed content of How to set python color. For more information, please follow other related articles on the PHP Chinese website!