用于在终端中打印颜色的跨平台轻量级软件包。

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

如果你想自己试试这个,你可以下载demo.py并尝试一下。在

就这样。这就是它的全部。在

Additional Noteinit_colorit()清除控制台,因此在打印输出之前,请将其放在代码中的某个位置。在

发布日志

  • 发布了ColorIt的第一个版本(v1.0.0)
  • 添加了许可证

支持我在帕特隆!在

这是我的patreon页面的链接:https://www.patreon.com/supermazingcoder:D

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java需要一种简单的方法来创建用于排序的comparator类   java getReadableDatabase和getWriteableDatabase无法解析   查找列表<Long>中与某个元素对应的所有索引的java方法   安卓将视图添加到ViewFlipper会导致java。StackOverflowerr语言   java根据它所包含的长“curTime”类字段将N的列表拆分为24(小时)   Android N中的Java8流API   自动生成Java策略文件的安全性   垃圾收集鼓励Java中的主要GC(但不是STW GC)   java如何检查UDP服务器上侦听的客户端数量   在前一台主机被Datastax Java驱动程序关闭后,Cassandra尝试重新连接到下一台主机   java如何使用Spring Boot创建部分代理   java是否有一个网站或资源可以完全比较EJB版本   java无需使用第三方库从gradle生成输出   继承由于这个多态性的基本示例中的语法有什么不同吗?(爪哇)   java字符串数组中的空字符串   java为什么CMS中的初始标记阶段是串行的   为什么Lucene有时与InChIKeys不匹配?   安卓通知Java应用程序数据库中的更改   java如何将单个json对象值解析为按钮   java打印堆栈将运行时错误跟踪到文件