Method 1
The output mode consists of three parts
\033 [font display mode; font color; font background color M ‘character’ \ 033 [0m]
Display mode: 0 (default), 1 (highlight), 22 (non BOLD), 4 (underline), 24 (non underline), 5 (flicker), 25 (non flicker), 7 (reverse display), 27 (non reverse display) font color: 30 (black), 31 (red), 32 (green), 33 (yellow), 34 (blue), 35 (magenta), 36 (cyan), 37 (white) font background color: 40 (black), 41 (red), 42 (green), 43 (yellow), 44 (blue), 45 (magenta), 46 (cyan), 47 (white)
from colorama import init
init(autoreset=True)
name = '谢辰辰'
print(f"\033[0;31m{name}\033[0m") #Output the red font
print(f"\033[0;31;42m{name}\033[0m") # Output the red font with green background color
Method 2
Setting colors with fore
from colorama import init,Fore
init(autoreset=True)
print (Fore.BLUE+'遇见你')
print(Fore.RED+'谢辰辰')
Read More:
- How to Fix Errors encountered in executing Python scripts with command line parameters
- Pychar can’t connect to Python console, but it can run. Py file, and Anaconda’s command line can run Python command
- Python: How to Set Line breaks and tabs for Strings
- Python uses try… Except… To output detailed errors
- python: File Processing and Input and Output
- How to Fix keyerror in Python dictionary lookup
- Python installs virtualenv through PIP and always reports an error: response.py“, line 438, in _error_catcher yield
- An introduction to sys modules in Python and how packages are imported and used
- Python: How to Costomize the Background of PS
- Chromdriver Install error: File “C:\python37\lib\site-packages\selenium\webdriver\common\service.py”, line 76, in start stdin=PIPE) File…
- Python: How to Solve multiprocessing module Error in Windows
- How to Solve Python WARNING: Ignoring invalid distribution -ip (e:\python\python_dowmload\lib\site-packages)
- [Solved] Ubuntu18.04 Install pyqt5 error: Command “python setup.py egg_info“ failed with error code 1 in /tmp/pip-build-92
- Python: How to Reshape the data in Pandas DataFrame
- Python: How to Delete Empty Files or Folders in the Directory
- Python: How to Create an Automatic Recording Program
- [Solved] NPM install Error: check python checking for Python executable python2 in the PATH
- Python: How to Solve mysqlclient Install Error in Mac
- Xadmin Install Error: Command “python setup.py egg_info“ failed with error code 1 in C:\Users\ADMINI~1\AppDat
- How to Fix “HTTP error 403: forbidden” in Python 3. X