How to print in colors - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: How to print in colors (/thread-2667.html) |
How to print in colors - JohnNo - Apr-01-2017 So I use python shell to do my stuff but I want to print out in color I tried everything from ANSI escape routes or ansicolors but nothing everything i try it does not print out in color so my question is. Can someone help me how to print out in color in shell thanks. Yeah I know this is stupid question, but I cant find anwser anywhere RE: How to print in colors - metulburr - Apr-01-2017 i just do something like... RED='\033[0;31m' GREEN='\033[1;32m' INVERT='\033[1;3m' NOCOLOR='\033[0m' def print_color(msg, color): '''print in color in terminal''' s = '{}{}{}'.format(color, msg, NOCOLOR) print(s) print_color('i am red', RED) print('nothing') print_color('i am green', GREEN)[attachment=149] There are modules to do such but i have never used them https://pypi.python.org/pypi/termcolor https://pypi.python.org/pypi/colorama RE: How to print in colors - wavic - Apr-01-2017 Colorama, termcolor, pygments These I remember. There are more for sure My favourite but I used it for something else: Blessings Just pick one! Have fun, make a rainbow |