Last active
June 6, 2021 15:27
-
-
Save dennisslimmers/0ec868e4a02146306d04731f13afd2ea to your computer and use it in GitHub Desktop.
Basic python function for printing pretty colored text (tested in Ubuntu 18.04 LTS)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sys | |
def cprintf(str, clr): | |
""" Basic colored printing """ | |
red = "\x1b[31m" | |
green = "\x1b[32m" | |
yellow = "\x1b[33m" | |
reset = "\x1b[0m" | |
if clr == 0: | |
print("%s%s%s" % (red, str, reset)) | |
elif clr == 1: | |
print("%s%s%s" % (green, str, reset)) | |
elif clr == 2: | |
print("%s%s%s" % (yellow, str, reset)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment