Python 轻量级控制台输出及文本格式化工具 - wasabi

作者: Anoyi

2021-01-09 21:26

⌛️ 安装

pip3 install wasabi

🎛 API

快速上手

msgPrinter 实例化对象,可以直接使用。

from wasabi import msg
msg.good("Hello Anoyi!")

普通文本 Printer.text

from wasabi import msg
msg.text("Hello Anoyi!")

特殊文本 Printer.good Printer.fail Printer.warn Printer.info

from wasabi import msg
msg.good("Success")
msg.fail("Error")
msg.warn("Warning")
msg.info("Info")

分隔符 Printer.divider

from wasabi import msg
msg.divider("Heading")

加载动画

from wasabi import msg
with msg.loading("Loading..."):
  # Do something here that takes longer
  time.sleep(10)
msg.good("Successfully loaded something!")

表格 table

from wasabi import msg, table

data = [("a1", "a2", "a3"), ("b1", "b2", "b3")]
header = ("Column 1", "Column 2", "Column 3")
widths = (8, 9, 10)
aligns = ("r", "c", "l")
formatted = table(data, header=header, divider=True, widths=widths, aligns=aligns)
print(formatted)

数据统计

from wasabi import msg
msg.good("Success")
msg.fail("Error")
msg.warn("Error")

print(msg.counts)
# Counter({'good': 1, 'fail': 1, 'warn': 1, 'info': 0})

参考文档

看法

看法

昵称
邮箱