Implementation process:
The character color of terminal is controlled by escape sequence, and it is the system display function in text mode, which is independent of the specific language.
The escape sequence begins with the ESC, which is done with \033 (the ASCII code for ESC is 27 in decimal notation, or 033 in octal).
Format:
opening Section :\033[display mode, foreground color, background colour m + End part:\033[0m
Note: the first part of the three parameters: Display mode, foreground color, background color is an optional parameter, you can write only one of them, in addition, because the three parameters of the different meaning of the values are unique and no duplicates, so the three parameters of the writing sequence is not fixed requirements, System can be recognized, however, it is recommended to write in the default format specification. for the end part, can also be omitted, but in order to write the specification, it is suggested \033[*** beginning, \033[0m end.
The meaning of the numeric parameter representation:
--------------------------------------------------------------------------------------Font Color| Background Color |Color Description------------------------------------------- | 40 |Black| 41 |Red| 42 |Green| 43 |Yellow color| 44 |Blue| 45 |Purplish Red| 46 |Cyan Blue| 47 |White--------------------------------------------------------------------------display Mode|effect------------------------------- |Terminal default Settings|Highlight Display|Use underline|flashing|anti-white display|not visible-------------------------------
Example:
Print ('\033[1;31;40m the account and password you entered is wrong! \033[0m')
Output: The account number and password you entered are incorrect!
Reference: https://www.cnblogs.com/hellojesson/p/5961570.html
Python Learning-terminal font highlighting