pip install RainbowPrint
remove rich_mode
in print_table
1. red
2. black
3. green
4. yellow
5. blue
6. magenta
7. cyan
8. white
from RainbowPrint import RainbowPrint as rp
print(rp.red('Hello World'))
print(rp.red('Hello World'),rp.green('Hello Rainbow Print'))
You can also pass in multiple strings
from RainbowPrint import RainbowPrint as rp
print(rp.red('Hello World','Hello RainbowPrint'))
There are three default color schemes:
from RainbowPrint import RainbowPrint as rp
rp.info("Hello World")
rp.debug("Hello World")
rp.error("hello World")
You can also customize color schemes using the rainbow_print
method
from RainbowPrint import RainbowPrint as rp
rp.rainbow_print("RainbowPrint",text_color=rp.TextColor.GREEN,background=rp.BackgroundColor.BLUE)
The rainbow_print
method takes 4 arguments:
data
,display_mode
, default value isDisplayMode.TERMINAL_DEFAULT_SETTINGS
text_color
, default value isTextColor.WHITE
background
, default value isBackgroundColor.RED
...
Beautify table print is supported starting with version 2.0 ^_^
from RainbowPrint import RainbowPrint as rp
table = []
title = ['name','email','phone','address']
row1 = ['huang','[email protected]',111,'jiangxi yichun']
row2 = ['jinxin','[email protected]','110119112','jiangsu jiangyin']
row3 = ['jinxin','[email protected]','110119112','jiangsu jiangyin']
row4 = ['jinxin','[email protected]','110119112','jiangsu jiangyin']
table.append(title)
table.append(row1)
table.append(row2)
table.append(row3)
table.append(row4)
rp.print_table(table, title, theme=rp.Table_Theme.BLUE_YELLOW,hilight=[2])
rp.print_table(table,title,border_style=rp.BorderStyle.SINGLE_LINE,hilight=[2])
rp.print_table(table, title, border_style=rp.BorderStyle.ROUND,hilight=[2])
The print_table
method takes 5 arguments:
table
, Two-dimensional tabletitle
, Table tiletheme
, Default value is Table_Theme.GREEN,border_style
, Default value is BorderStyle.DEFAULT.value. There are three options:ROUND
,SINGLE_LINE
,DEFAULT
hilight
, Default value is[]
. Specifies the columns that need to be highlighted, such ashilight=[2]
alignment
, Default value isrp.Alignment.LEFT
,There are three options:rp.Alignment.MID
,rp.Alignment.LEFT
,rp.Alignment.RIGTH