How to get colored output to the console

Define the following,

bcolors


class pycolor:
    BLACK = '\033[30m'
    RED = '\033[31m'
    GREEN = '\033[32m'
    YELLOW = '\033[33m'
    BLUE = '\033[34m'
    PURPLE = '\033[35m'
    CYAN = '\033[36m'
    WHITE = '\033[37m'
    END = '\033[0m'
    BOLD = '\038[1m'
    UNDERLINE = '\033[4m'
    INVISIBLE = '\033[08m'
    REVERCE = '\033[07m'

main


print pycolor.RED + "RED TEXT" + pycolor.END

And run

RED TEXT

Is output. Don't forget to add pycolor.END when you're done.

Recommended Posts

How to get colored output to the console
How to overwrite the output to the console
How to get the Python version
I want to output to the console coolly
How to operate Linux from the console
How to print debug messages to the Django console
How to erase the characters output by Python
How to get the files in the [Python] folder
How to get the variable name itself in python
How to get the number of digits in Python
How to use the generator
[NNabla] How to get the output (variable) of the middle layer of a pre-built network
[Python] How to output the list values in order
How to use the decorator
How to increase the axis
How to start the program
How to get the last (last) value in a list in Python
How to get all the keys and values in the dictionary
How to get into the python development environment with Vagrant
Keras I want to get the output of any layer !!
[Shell] How to get the remote default branch in Git
How to print characters to the console before booting on ARM
[Introduction to Python] How to get data with the listdir function
Post Jenkins console output to Slack
How to calculate the autocorrelation coefficient
How to use the zip function
How to read the SNLI dataset
How to get started with Scrapy
How to get started with Python
[Python] How to import the library
How to get started with Django
How to use the ConfigParser module
How to set the output resolution for each keyframe in Blender
How to get and set the NTP server name by DHCP
python / pandas / dataframe / How to get the simplest row / column / index / column
How to get all the possible values in a regular expression
How to get the ID of Type2Tag NXP NTAG213 with nfcpy
How to get the printer driver for Oki Mac into Linux
How to get followers and followers from python using the Mastodon API
[Python] How to get the first and last days of the month
How to get the directory where the EXE built with Pyinstaller exists
How to get the vertex coordinates of a feature in ArcPy
How to display the progress bar (tqdm)
How to get parent id with sqlalchemy
How to get rid of long comprehensions
How to check the version of Django
How to solve the bin packing problem
How to get IP when Tornado + nginx
How to set the server time to Japanese time
Output Python log to console with GAE
How to manually update the AMP cache
[Linux] How to use the echo command
How to use the Linux grep command
Get the path to the systemd unit file
How to get a stacktrace in python
How to access the Datastore from the outside
How to use the IPython debugger (ipdb)
How to get started with laravel (Linux)
[Python Kivy] How to get the file path by dragging and dropping
How to get the date and time difference in seconds with python
How to assign multiple values to the Matplotlib colorbar