用于在终端中打印颜色的跨平台轻量级软件包。
color-it的Python项目详细描述
彩色
为输出添加颜色的简单库。在
你有没有想过把颜色打印到主机上?我当然有。总有一天你会意识到这是必要的。所以我创造了ColorIt。ColorIt是一种将颜色打印到控制台的超级简单方法。在
工作原理
在内部,库创建带有RGB值的自定义ANSI序列。这意味着有16种颜色可以使用!在
安装
安装colorit
。在Windows上运行pip install color-it
,或者在macOS和Linux上运行pip3 install color-it
,从那里可以用import colorit
导入它
如何使用它
要使用ColorIt:
fromcoloritimport*# Use this to ensure that ColorIt will be usable by certain command line interfacesinit_colorit()# Foregroundprint(color("This text is red",Colors.red))print(color("This text is orange",Colors.orange))print(color("This text is yellow",Colors.yellow))print(color("This text is green",Colors.green))print(color("This text is blue",Colors.blue))print(color("This text is purple",Colors.purple))print(color("This text is white",Colors.white))# Backgroundprint(background("This text has a background that is red",Colors.red))print(background("This text has a background that is orange",Colors.orange))print(background("This text has a background that is yellow",Colors.yellow))print(background("This text has a background that is green",Colors.green))print(background("This text has a background that is blue",Colors.blue))print(background("This text has a background that is purple",Colors.purple))print(background("This text has a background that is white",Colors.white))# Customprint(color("This color has a custom grey text color",(150,150,150)))print(background("This color has a custom grey background",(150,150,150)))# Combinationprint(background(color("This text is blue with a white background",Colors.blue),Colors.white))# If you are using Windows Command Line, this is so that it doesn't close immediatelyinput()
作为输出:
如果你想自己试试这个,你可以下载demo.py
并尝试一下。在
就这样。这就是它的全部。在
Additional Note:init_colorit()
清除控制台,因此在打印输出之前,请将其放在代码中的某个位置。在
发布日志
- 发布了ColorIt的第一个版本(v1.0.0)
- 添加了许可证
支持我在帕特隆!在
这是我的patreon页面的链接:https://www.patreon.com/supermazingcoder:D
- 项目
标签: