Created
February 5, 2018 19:02
-
-
Save gdlmx/d59b94d5100b4a1e86ce5ec01c9b8eda to your computer and use it in GitHub Desktop.
Print ANSI Color in Python
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
#!/usr/bin/env python | |
import os,sys | |
class BCOLOR: | |
if sys.stdout.isatty(): | |
HEADER = '\033[95m' | |
OKBLUE = '\033[94m' | |
OKGREEN = '\033[92m' | |
WARNING = '\033[93m' | |
FAIL = '\033[91m' | |
ENDC = '\033[0m' | |
BOLD = '\033[1m' | |
UNDERLINE = '\033[4m' | |
def __getattr__(self,name): | |
return '' | |
bcolors=BCOLOR() | |
print(bcolors.OKBLUE, 'Yes', bcolors.ENDC, '/', bcolors.FAIL, 'No', bcolors.ENDC) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment