Last active
January 10, 2020 16:23
-
-
Save clementsjj/c0184c58df7661ff2ee3920b4bdad9bf to your computer and use it in GitHub Desktop.
Revisions
-
clementsjj revised this gist
Jan 10, 2020 . 1 changed file with 24 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -13,4 +13,27 @@ def colorize(color, text): return colortext print(colorize(f['red'], 'Hello, World!') # Hello, World! (In Red) # Alternatively, a function wrapper for each specific color can easily be dropped into any project... def red(text): # Will print in Red colortext = f'\033[31m{text}\033[00m' return colortext def blue(text): # Will Print in Blue colortext = f'\033[34m{text}\033[00m' return colortext def magenta(text): colortext = f'\033[35m{text}\033[00m' return colortext def cyan(text): colortext = f'\033[36m{text}\033[00m' return colortext -
clementsjj created this gist
Dec 4, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ f = {'red':'31m', 'green':'32m', 'yellow':'33m', 'blue':'34m', 'magenta':'35m', 'cyan':'36m', 'lightgray':'37m', 'darkgray':'90m', 'white':'97m'} def colorize(color, text): colortext=f'\033[{color}{text}\033[00m' return colortext print(colorize(f['red'], 'Hello, World!') # Hello, World! (In Red)