Skip to content

Instantly share code, notes, and snippets.

@phanthaihuan
Created May 13, 2020 16:44
Show Gist options
  • Save phanthaihuan/7fcd9fe3da75f3d46b0861aea0f712d4 to your computer and use it in GitHub Desktop.
Save phanthaihuan/7fcd9fe3da75f3d46b0861aea0f712d4 to your computer and use it in GitHub Desktop.
How to print colored text to terminal in Python
def prRed(prt): print("\033[91m {}\033[00m" .format(prt))
def prGreen(prt): print("\033[92m {}\033[00m" .format(prt))
def prYellow(prt): print("\033[93m {}\033[00m" .format(prt))
def prLightPurple(prt): print("\033[94m {}\033[00m" .format(prt))
def prPurple(prt): print("\033[95m {}\033[00m" .format(prt))
def prCyan(prt): print("\033[96m {}\033[00m" .format(prt))
def prLightGray(prt): print("\033[97m {}\033[00m" .format(prt))
def prBlack(prt): print("\033[98m {}\033[00m" .format(prt))
prGreen("Hello world")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment