A library for working with the color formats defined by HTML and CSS.
Project description
webcolors is a module for working with and converting between the various HTML/CSS color formats.
Support is included for normalizing and converting between the following formats (RGB colorspace only; conversion to/from HSL can be handled by the colorsys module in the Python standard library):
Specification-defined color names
Six-digit hexadecimal
Three-digit hexadecimal
Integer rgb() triplet
Percentage rgb() triplet
For example:
>>> import webcolors
>>> webcolors.hex_to_name("#daa520")
'goldenrod'
Implementations are also provided for the HTML5 color parsing and serialization algorithms. For example, parsing the infamous “chucknorris” string into an rgb() triplet:
>>> import webcolors
>>> webcolors.html5_parse_legacy_color("chucknorris")
HTML5SimpleColor(red=192, green=0, blue=0)
Full documentation is available online.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for webcolors-24.8.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc4c3b59358ada164552084a8ebee637c221e4059267d0f8325b3b560f6c7f0a |
|
MD5 | 757533d6870098d36edfafcebf2fd009 |
|
BLAKE2b-256 | f03312020ba99beaff91682b28dc0bbf0345bbc3244a4afbae7644e4fa348f23 |