Skip to content

Instantly share code, notes, and snippets.

@ricrogz
Created July 24, 2016 20:47
Show Gist options
  • Save ricrogz/bc703072dd101cf0cf6b39edd4540557 to your computer and use it in GitHub Desktop.
Save ricrogz/bc703072dd101cf0cf6b39edd4540557 to your computer and use it in GitHub Desktop.
Python: colors on console output
import colorama
# Optional?? I did not put it in my code, and outputs colors just fine.
# colorama.init()
print(colorama.Fore.RED + 'some red text')
print(colorama.Back.GREEN + 'and with a green background')
print(colorama.Style.DIM + 'and in dim text')
print(colorama.Style.RESET_ALL)
print('back to normal now')
"""
Fore: BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET.
Back: BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET.
Style: DIM, NORMAL, BRIGHT, RESET_ALL
Style.BRIGHT makes text bold.
Style.RESET_ALL resets both style and colors.
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment