ansi-styles
ANSI escape codes for styling strings in the terminal
A port of the Node.js package ansi-styles to Python.
Install
python3 -m pip install -U ansi-styles
Usage
from ansi_styles import ansiStyles as styles
print(f'{styles.green.open}Hello world!{styles.green.close}')
# Color conversion between 256/truecolor
# NOTE: When converting from truecolor to 256 colors, the original color
# may be degraded to fit the new color palette. This means terminals
# that do not support 16 million colors will best-match the
# original color.
print(f'{styles.color.ansi(styles.rgbToAnsi(199, 20, 250))}Hello World{styles.color.close}')
print(f'{styles.color.ansi256(styles.rgbToAnsi256(199, 20, 250))}Hello World{styles.color.close}')
print(f'{styles.color.ansi16m(*styles.hexToRgb("#abcdef"))}Hello World{styles.color.close}')
License
MIT
Contact
A library by Shawn Presser. If you found it useful, please consider joining my patreon!
My Twitter DMs are always open; you should send me one! It's the best way to reach me, and I'm always happy to hear from you.
- Twitter: @theshawwn
- Patreon: https://www.patreon.com/shawwn
- HN: sillysaurusx
- Website: shawwn.com
Metadata
Release files for ansi-styles 0.2.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 |
|---|---|---|---|---|
| ansi-styles-0.2.2.tar.gz | 3.6 kB | Without provenance | Details for ansi-styles-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ansi_styles-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for ansi_styles-0.2.2-py3-none-any.whl |
Total release size: 7.2 kB
Release files / ansi-styles-0.2.2.tar.gz
| Download URL | ansi-styles-0.2.2.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
70340cbe98126ea9c836932d7f111e36bd93561ae108b8c437d9422269fdf2c2
|
|
BLAKE2b-256 checksum How to use checksums |
fb88d741860a255a5fa2915e80b9f847c134946df34b1761edef7a51bed09df1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.6 CPython/3.9.2 Darwin/20.3.0
|
Release files / ansi_styles-0.2.2-py3-none-any.whl
| Download URL | ansi_styles-0.2.2-py3-none-any.whl |
|---|---|
| Size | 3.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
89fe3b462f089bf72ce5a97604b9f9db35d7207c8092324b984395ef0f1a1b44
|
|
BLAKE2b-256 checksum How to use checksums |
74084abffd5df722cf4dd51aadbc81a64bc17807338298156a13ff01cd75371f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.6 CPython/3.9.2 Darwin/20.3.0
|
Security for ansi-styles 0.2.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.