DEV Community 👩‍💻👨‍💻

threadspeed
threadspeed

Posted on

Terminal style with Python

style is a simple terminal string styling package for Python. Its API is a port of the popular chalk package for javascript.

Install the module style with pip:

$ pip install style

Usage is like this:

import style
print(style.red('Hello', style.bold('world') + '!'))

Some messing around with the Python shell:

text color python

Styles available:

  • bold
  • dim
  • italic
  • underline
  • inverse
  • hidden
  • strikethrough

Colors available:

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

  • light_black

  • light_red

  • light_green

  • light_yellow

  • light_blue

  • light_magenta

  • light_cyan

  • light_white

  • on_black

  • on_red

  • on_green

  • on_yellow

  • on_blue

  • on_magenta

  • on_cyan

  • on_white

  • on_light_black

  • on_light_red

  • on_light_green

  • on_light_yellow

  • on_light_blue

  • on_light_magenta

  • on_light_cyan

  • on_light_white

Top comments (0)

🌚 Turn on dark mode

🔠 Change your default font

📚 Adjust your experience level to see more relevant content

Head to your account's Settings to do all this and more.