Skip to content

Instantly share code, notes, and snippets.

@gdlmx
Created February 5, 2018 19:02
Show Gist options
  • Save gdlmx/d59b94d5100b4a1e86ce5ec01c9b8eda to your computer and use it in GitHub Desktop.
Save gdlmx/d59b94d5100b4a1e86ce5ec01c9b8eda to your computer and use it in GitHub Desktop.
Print ANSI Color in Python
#!/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