Skip to content

Instantly share code, notes, and snippets.

@DevGW
Last active May 4, 2023 20:12
Show Gist options
  • Save DevGW/f6d3a0a811c521d22731081a7818cd3d to your computer and use it in GitHub Desktop.
Save DevGW/f6d3a0a811c521d22731081a7818cd3d to your computer and use it in GitHub Desktop.
Python ANSI color class #python #ANSI
class ansi_colors:
RED = '\033[91m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
BLUE = '\033[94m'
PURPLE = '\033[95m'
CYAN = '\033[96m'
ENDC = '\033[0m' # Reset
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
ITALIC = '\033[3m'
# Importing:
from ansi_colors import ansi_colors as colors
# Usage:
print(f"{ansi_colors.YELLOW}This text is yellow.{ansi_colors.ENDC}")
print(f"{ansi_colors.BLUE}This text is blue.)
print("This text is also blue.")
print(f"{ansi_colors.ENDC}This text is reset to normal.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment