colorprint('violet text', color=Fore.violet)
colorprint('brown text', color='brown', bold=True)
Printer.blue_print('blue text') # output blue text
Printer.red_print('red text', bold=True) # output bold red text
Printer.cyan_print('cyan text', file=sys.stderr) # output cyan text to sys.stderr
Printer
Here are some example printer:
blue_print
blue_print (*value, bold=False, sep=' ', end='\n', file=<_io.StringIO
object at 0x7fd6cd0ae160>, flush=False)
Prints the values to a stream, or to sys.stdout by default with Fore.blue
color.
violet_print
violet_print (*value, bold=False, sep=' ', end='\n', file=<_io.StringIO
object at 0x7fd6cd0ae160>, flush=False)
Prints the values to a stream, or to sys.stdout by default with Fore.violet
color.
yellow_print
yellow_print (*value, bold=False, sep=' ', end='\n', file=<_io.StringIO
object at 0x7fd6cd0ae160>, flush=False)
Prints the values to a stream, or to sys.stdout by default with Fore.yellow
color.
Here are other available printers:
Code
def _get_background(name):
color = name[:-6]
background = (
Back['75, 70, 75']
if sum(Color[color].rgb) / 3 > 165 else
Back['240, 250, 250']
)
return background
for i, printer in enumerate(Printer.available, 1):
end = '\n' if i%3 == 0 else '\t'
background = _get_background(printer)
print(background, end='')
getattr(Printer, printer)(f'{printer:28}', bold=True, end=end)
source
colorprint
colorprint (*value, color=None, background=None, bold=False, sep=' ',
end='\n', file=<_io.StringIO object at 0x7fd6cd0ae160>,
flush=False)
Prints the values to a stream, or to sys.stdout by default with Fore.color
color.
value |
|
|
|
color |
NoneType |
None |
Text color. Acceptable format: ‘red’, Fore.red, ‘#ff0000’, (255, 0, 0) |
background |
NoneType |
None |
background color. Acceptable format: ‘red’, Back.red, ‘#ff0000’, (255, 0, 0) |
bold |
bool |
False |
Whether to use bold font |
sep |
str |
|
String inserted between values, default a space. |
end |
str |
|
String appended after the last value, default a newline. |
file |
StringIO |
<_io.StringIO object at 0x7fd6cd0ae160> |
A file-like object (stream); defaults to the current sys.stdout. |
flush |
bool |
False |
Whether to forcibly flush the stream. |
colorprint('default')
colorprint('#ff3567', color='#ff3567')
colorprint('#123456', color=Fore['#123456'])
colorprint(4, color=4)
colorprint(137, color=Fore['137'])
colorprint('(50, 234, 33)', color=(50, 234, 33))
colorprint('(50, 24, 133)', color='(50, 24, 133)')
colorprint('dark_green', color=Fore.dark_green)
colorprint('violet', background='violet', bold=False)
colorprint('violet', background='violet', bold=True)
colorprint('violet', color=Fore.green, background='violet', bold=True)