String colorize module for Python 3.x
Color chart
$ pip install color
or
$ easy_install color
or make it
$ python setup.py install
# -*- coding: utf-8 -*-
#
# You use to specific functions
#
# from color import colorize
# from color import uncolorize
from color import *
# colorize function. set the other code.
print(colorize(38, 5, 197, 'foo bar baz'))
# uncolorize function
print(uncolorize(red('foo')))
# tr function.
print(tr('foo bar baz', 'o', FgColor.Red)) # colorized: 'o' chars.
print(tr('foo bar baz', 'foo', FgColor.Yellow)) # colorized: 'foo' words.
# tr_iter function.
print(tr_iter('foo bar baz', 'oa', FgColor.Green)) # colorized: all of 'o' and 'a' chars.
# cprint function.
cprint('hellooo', base=Base.Bold)
cprint('foo bar', fg=FgColor.Red, file=sys.stderr)
cprint('foo') # Stdout
# OTHERS
r = red('ops!')
g = green('hmmm...')
cprint(r, g)
cprint_yellow('yooo!!!')
cprint_green('success')
cprint_black('cocoa bitter')
# ...
The MIT License (MIT) - see LICENSE for more details