table.add_column("数值", justify="right", style="green") table.add_row("2022年","国民总收入指数","4432.1") table.add_row("2021年","国民总收入指数","4319.7") table.add_row("2020年","国民总收入指数","3979.1") table.add_row("2019年","国民总收入指数","3912.1") console = Console...
Rich的Table类提供了多种将表格数据呈现到终端的方法。Table类具有 add_column()和add_row()方法,用于将列和行分别添加到Table中。 Table 代码语言:javascript 代码运行次数:0 运行 AI代码解释 from rich.console import Console from rich.table import Table table = Table(title="Todo List") table.add_column...
Rich 可以使用 Unicode 框字符来呈现多变的 表格。 Rich 包含多种边框,样式,单元格对齐等格式设置的选项。 python fromrich.consoleimportConsole fromrich.tableimportColumn,Table console=Console table=Table(show_header=True,header_style="bold magenta") table.add_column("Date",style="dim",width=12) tabl...
fromrich.consoleimportConsolefromrich.tableimportTable console=Console()table=Table(show_header=True,header_style="bold magenta")table.add_column("Name",style="dim",width=12)table.add_column("Age",style="dim",width=8)table.add_column("Gender",style="dim",width=10)table.add_row("Alice","...
table.add_row("Dec 15, 2017","Star Wars Ep. VIII: The Last Jedi","$262,000,000","[bold]$1,332,539,889[/bold]", ) console.print(table) 进度条 使用progress模块输出进度条: importtimefromrich.progressimporttrackdefdo_step(step): ...
from rich import inspect import rich inspect(rich) 1. 2. 3. 4. 5. 使用Tree显示文件系统等树状结构 from rich.tree import Tree from rich import print as rprint tree = Tree("Family Tree") tree.add("Mom") tree.add("Dad") tree.add("Brother").add("Wife") ...
Rich 包含多种边框,样式,单元格对齐等格式设置的选项。下面是一个简单的示例: from rich.console import Console from rich.table import Column, Table console = Console() table = Table(show_header=True, header_style="bold magenta") table.add_column("Date", style="dim", width=12) ...
from rich.console import Console from rich.table import Table console = Console() table = Table(show_header=True, header_style="bold magenta") table.add_column("Date", style="dim", width=12) table.add_column("Title") table.add_column("Production Budget", justify="right") table.add_col...
from rich.tableimportTable console=Console()table=Table(show_header=True,header_style="bold magenta")table.add_column("Date",style="dim",width=12)table.add_column("Title")table.add_column("Production Budget",justify="right")table.add_column("Box Office",justify="right")table.add_row("Dec...
"$538 million")table.add_row("1983", "Star Wars: Episode VI - Return of the Jedi", "$475 million")console.print(table)这段代码会在终端中生成一个漂亮的表格,展示了前三部星球大战电影的信息。另一个常用的功能是进度条。在处理长时间运行的任务时,进度条能够给用户很好的反馈:from rich.progres...