Skip to main content

ANSI color formatting for output in terminal

Project description

termcolor

PyPI version Supported Python versions PyPI downloads GitHub Actions status Codecov Licence Code style: Black

Example

import sys

from termcolor import colored, cprint

text = colored("Hello, World!", "red", attrs=["reverse", "blink"])
print(text)
cprint("Hello, World!", "green", "on_red")

print_red_on_cyan = lambda x: cprint(x, "red", "on_cyan")
print_red_on_cyan("Hello, World!")
print_red_on_cyan("Hello, Universe!")

for i in range(10):
    cprint(i, "magenta", end=" ")

cprint("Attention!", "red", attrs=["bold"], file=sys.stderr)

Text properties

Text colors:

  • grey
  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • white

Text highlights:

  • on_grey
  • on_red
  • on_green
  • on_yellow
  • on_blue
  • on_magenta
  • on_cyan
  • on_white

Attributes:

  • bold
  • dark
  • underline
  • blink
  • reverse
  • concealed

Terminal properties

Terminal bold dark underline blink reverse concealed
xterm yes no yes bold yes yes
linux yes yes bold yes yes no
rxvt yes no yes bold/black yes no
dtterm yes yes yes reverse yes yes
teraterm reverse no yes rev/red yes no
aixterm normal no yes no yes yes
PuTTY color no yes no yes no
Windows no no no no yes no
Cygwin SSH yes no color color color yes
Mac Terminal yes no yes yes yes yes

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

termcolor-2.0.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

termcolor-2.0.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file termcolor-2.0.0.tar.gz.

File metadata

  • Download URL: termcolor-2.0.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.14

File hashes

Hashes for termcolor-2.0.0.tar.gz
Algorithm Hash digest
SHA256 4889f2243b1da3934fc6cf4b57ee50a0ce98065ec06bfddac3fa6db24a9fcde2
MD5 d64df8a9578e3eed8350819b3e9625da
BLAKE2b-256 d7998fd6784741a4f533aa1da09c45a3dfbeb7d0454cc653384a6eefd958cf3d

See more details on using hashes here.

File details

Details for the file termcolor-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: termcolor-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.14

File hashes

Hashes for termcolor-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6e1a4b8e9c064ad8f9dfe2f9b35a7871d6ea5b6bb4f9da55bc0fd494b2302204
MD5 f9306ac8f8f09304242af99fe3391eaa
BLAKE2b-256 4f766aef5db121bd67ccfa9ce8f7d2703231f58e5a5221e1782f68b6c8f12e5c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page