Print text color and text format on Term with Python
term-printer
Print ‘text color’ and ‘text format’ on Term with Python
※ It may not work depending on the OS and shell used.
PIP
$ pip install term-printer
import
from term_printer import Color, Color256, ColorRGB, StdText, cprint
If you want to override bultin print
function
from term_printer import Color, Color256, ColorRGB, StdText, cprint as print
Usage
1. Attrs print
Applies to all characters.
You can specify Format
, Color
, Color256
, and ColorRGB
.
Able to specify more than one.
source
from term_printer import Color, Color256, ColorRGB, Format, cprint
# default
cprint("this is a default pen")
# bold
cprint("this is a bold pen", attrs=[Format.BOLD])
# italic
cprint("this is a italic pen", attrs=[Format.ITALIC])
# red color
cprint("this is a red pen", attrs=[Color.RED])
# bright