Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thep0y/colort
终端中的彩色显示
https://github.com/thep0y/colort
Last synced: 22 days ago
JSON representation
终端中的彩色显示
- Host: GitHub
- URL: https://github.com/thep0y/colort
- Owner: thep0y
- License: mit
- Created: 2021-05-27T00:30:51.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-09T13:05:09.000Z (about 1 year ago)
- Last Synced: 2024-09-17T13:38:41.518Z (about 2 months ago)
- Language: Python
- Size: 19.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Colort
This module provides functions for formatting text with ANSI escape codes to add color and style.
## Installation
```shell
pip install colort
```## Usage
```python
from colort import colorize
```The `colorize` function takes a string and any number of `Style` and `*Color` enums. It returns the string formatted with the specified styles.
For example:
```python
from colorformat import colorize, ForegroundColor as fc, Stylecolored_text = colorize('Hello World!', fc.GREEN, Style.BOLD)
print("colored text: ", colored_text)
```This will print the text in bold and green.
![截屏2023-08-06 11.03.47](https://s1.ax1x.com/2023/08/06/pPANNxs.png)
The available formatting options are:
### Colors
- ForegroundColor
- BLACK, RED, GREEN, YELLOW, BLUE, etc.
- BackgroundColor
- BLACK, RED, GREEN, YELLOW, BLUE, etc.### Styles
- Style
- NORMAL, BOLD, UNDERLINE, BLINK, INVERT, HIDEMultiple styles can be combined:
```python
colorize('Text', ForegroundColor.WHITE, BackgroundColor.RED, Style.BOLD)
```