Skip to content

Instantly share code, notes, and snippets.

@thevickypedia
Last active February 9, 2022 00:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thevickypedia/7ca5b232e08c08950d18e905496fb3ce to your computer and use it in GitHub Desktop.
Save thevickypedia/7ca5b232e08c08950d18e905496fb3ce to your computer and use it in GitHub Desktop.
Format text in python's print statements
class Format:
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
ITALIC = '\x1B[3m'
class Colors:
VIOLET = '\033[95m'
BLUE = '\033[94m'
CYAN = '\033[96m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
END = '\033[0m'
LIGHT_GREEN = '\033[32m'
LIGHT_YELLOW = '\033[2;33m'
LIGHT_RED = '\033[31m'
print(f"{Format.UNDERLINE}{Colors.VIOLET}I will print in 'VIOLET', 'UNDERLINE' text{Colors.END}")
print(f"{Format.BOLD}{Colors.BLUE}I will print in 'BLUE', 'BOLD' text{Colors.END}")
print(f"{Colors.CYAN}I will print in 'CYAN'{Colors.END}")
print(f"{Colors.GREEN}I will print in 'GREEN'{Colors.END}")
print(f"{Colors.YELLOW}I will print in 'YELLOW'{Colors.END}")
print(f"{Colors.RED}I will print in 'RED'{Colors.END}")
print(f"{Colors.LIGHT_RED}I will print in basic 'RED'{Color.END}")
print(f"{Colors.LIGHT_YELLOW}I will print in basic 'YELLOW'{Color.END}")
print(f"{Colors.LIGHT_GREEN}I will print in basic 'GREEN'{Color.END}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment