python 控制台文本的基本色
介绍:
-
为你的 python 脚本在控制台的输出上个色!
-
0.1.0版本支持win 和linux
-
跟 0.0.2 版本不同,由于考虑兼容性,0.1.0 版本之后会直接打印文本,不会返回包装后的文本!务必注意
-
win平台只打印文本颜色,背景色和显示效果(闪烁等)暂时无效果
简要使用说明:
安装:
$ pip install basecolors
终端命令:
$ colorit [-t --text [-fc --front_color] [-bc --back_color] [-md --show_mode]] [-a --show_all [-ne --show_all_but_no_effect]]
# 显示帮助:
$ colorit -h
-
参数解释:
- -t --text 需要上色的文本
- -fc --front_color 字体颜色
- -bc --back_color 背景色
- -md --show_mode 显示模式,加深、闪烁、下划线等
- -a --show_all 显示所有颜色名称和代号
- -ne --show_all_but_no_effect 配合 -a 参数,显示颜色名称和代号但不展示效果
终端示例:
# 显示红色字样
$ colorit -fc red
# 显示红色加粗字样
$ colorit -t 测试文本 -fc red -md highlight
# 显示黄色下划线字样
$ colorit -fc yellow -md underline
# 显示蓝色闪烁字样
$ colorit -fc blue -md blinking
# 如果不确定颜色或显示模式的名称,可以输入 colorit -a -ne 或者 colorit -a 查看
代码中调用:
from BaseColor.base_colors import *
# 0.0.1 版本(只支持 linux):
print(red("测试文本")) # 普通红色
print(hred("测试文本")) # 加粗红色
# 0.1.0 版本(新版,支持 win 和 linux):
red("测试文本")
# ============ linux 效果 ===============
# 其他颜色也有普通和加粗显示的区别,就是在前面多个 h,例如上面的 red 和 hred
# 其他配合颜色的 show_mode 暂时没有编写
# 自定义颜色效果组合:
color("测试文本", show_mode="underline", back_color="cyan", front_color="red")
# 效果可以叠加使用,例如同时加粗和闪烁:
hred(color("测试文本", 'blinking'))
Metadata
Release files for basecolors 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| basecolors-0.1.2.tar.gz | 6.4 kB | Without provenance | Details for basecolors-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| basecolors-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for basecolors-0.1.2-py3-none-any.whl |
Total release size: 13.3 kB
Release files / basecolors-0.1.2.tar.gz
| Download URL | basecolors-0.1.2.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a6ad3b358303034e56fb74b75a470ba3bc1fb4ed116974c01a97b443f2bdaece
|
|
BLAKE2b-256 checksum How to use checksums |
1ba0dbfe9c1b8f86bb1f20af17f152c2964430065b2a9ca2dfdeb48275e396a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.18
|
Release files / basecolors-0.1.2-py3-none-any.whl
| Download URL | basecolors-0.1.2-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9da29e53a9f1631808bae3e8fa9a7aed94d29cb6bb4c709321b01b577ed00b0a
|
|
BLAKE2b-256 checksum How to use checksums |
d200e71c5555030092e25e352f1e0ee28b6db0e983eccaa05d9264f653fc3f7a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.18
|
Security for basecolors 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.