DEV Community

0xkoji
0xkoji

Posted on • Updated on

 

Make log Colorful with Python

install colorama

$ pip install colorama
Enter fullscreen mode Exit fullscreen mode

code

test.py

from colorama import Fore, Back, Style

print('===========================')
print(Fore.GREEN + "green string")
print(Style.DIM + "dim: test")
print(Style.BRIGHT + "BRIGHT: test")
print(Style.NORMAL + "NORMAL: test")
print(Style.RESET_ALL + "RESET_ALL")
print(Back.GREEN + 'green')
print(Style.RESET_ALL)
print('===========================')
print(Fore.RED + "red string")
print(Style.DIM + "dim: test")
print(Style.BRIGHT + "BRIGHT: test")
print(Style.NORMAL + "NORMAL: test")
print(Style.RESET_ALL + "RESET_ALL")
print(Back.RED + 'red')
print(Style.RESET_ALL)
print('===========================')
print(Fore.YELLOW + "yellow string")
print(Style.DIM + "dim: test")
print(Style.BRIGHT + "BRIGHT: test")
print(Style.NORMAL + "NORMAL: test")
print(Style.RESET_ALL + "RESET_ALL")
print(Back.YELLOW + 'yellow')
print(Style.RESET_ALL)
print('===========================')
print(Fore.BLUE + "blue string")
print(Style.DIM + "dim: test")
print(Style.BRIGHT + "BRIGHT: test")
print(Style.NORMAL + "NORMAL: test")
print(Style.RESET_ALL + "RESET_ALL")
print(Back.BLUE + 'blue')
print(Style.RESET_ALL)
Enter fullscreen mode Exit fullscreen mode

result

Top comments (0)

Timeless DEV post...

Git Concepts I Wish I Knew Years Ago

The most used technology by developers is not Javascript.

It's not Python or HTML.

It hardly even gets mentioned in interviews or listed as a pre-requisite for jobs.

I'm talking about Git and version control of course.

One does not simply learn git