Skip to content

Instantly share code, notes, and snippets.

@alepmaros
Created September 3, 2018 16:49
Show Gist options
  • Save alepmaros/30e343585a314265646278c38b8ec80f to your computer and use it in GitHub Desktop.
Save alepmaros/30e343585a314265646278c38b8ec80f to your computer and use it in GitHub Desktop.
Python Print Colors
def print_format_table():
"""
prints table of formatted text format options
"""
for style in range(8):
for fg in range(30,38):
s1 = ''
for bg in range(40,48):
format = ';'.join([str(style), str(fg), str(bg)])
s1 += '\x1b[%sm %s \x1b[0m' % (format, format)
print(s1)
print('\n')
print_format_table()
# Example
print('\x1b[0;30;43mWARNING: {}\x1b[0m'.format('something'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment