如何从 ansicolor 迁移到 ansicolors

Python 中的 ansicolor 包已经很长时间没有更新,并且在 PyPI 上没有任何文档。因此,我将我的 Python 脚本迁移到 ansicolors(末尾有 s)。只需几个步骤:

首先,替换

how-to-migrate-from-ansicolor-to-ansicolors.py
from ansicolor import red

ansicolors_usage_example.py
from colors import red

此外,bold=Trueansicolors 中称为 style="bold",因此你需要替换

ansicolors_style_change_example.py
red("msg", bold=True)

ansicolors_style_new.py
red("msg", style="bold")

Check out similar posts by category: Python