合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
### 导航 - [索引](../genindex.xhtml "总目录") - [模块](../py-modindex.xhtml "Python 模块索引") | - [下一页](imghdr.xhtml "imghdr --- 推测图像类型") | - [上一页](chunk.xhtml "chunk --- Read IFF chunked data") | - ![](https://box.kancloud.cn/a721fc7ec672275e257bbbfde49a4d4e_16x16.png) - [Python](https://www.python.org/) » - zh\_CN 3.7.3 [文档](../index.xhtml) » - [Python 标准库](index.xhtml) » - [多媒体服务](mm.xhtml) » - $('.inline-search').show(0); | # [`colorsys`](#module-colorsys "colorsys: Conversion functions between RGB and other color systems.") --- Conversions between color systems **Source code:** [Lib/colorsys.py](https://github.com/python/cpython/tree/3.7/Lib/colorsys.py) \[https://github.com/python/cpython/tree/3.7/Lib/colorsys.py\] - - - - - - The [`colorsys`](#module-colorsys "colorsys: Conversion functions between RGB and other color systems.") module defines bidirectional conversions of color values between colors expressed in the RGB (Red Green Blue) color space used in computer monitors and three other coordinate systems: YIQ, HLS (Hue Lightness Saturation) and HSV (Hue Saturation Value). Coordinates in all of these color spaces are floating point values. In the YIQ space, the Y coordinate is between 0 and 1, but the I and Q coordinates can be positive or negative. In all other spaces, the coordinates are all between 0 and 1. 参见 More information about color spaces can be found at <http://poynton.ca/ColorFAQ.html> and <https://www.cambridgeincolour.com/tutorials/color-spaces.htm>. The [`colorsys`](#module-colorsys "colorsys: Conversion functions between RGB and other color systems.") module defines the following functions: `colorsys.``rgb_to_yiq`(*r*, *g*, *b*)Convert the color from RGB coordinates to YIQ coordinates. `colorsys.``yiq_to_rgb`(*y*, *i*, *q*)Convert the color from YIQ coordinates to RGB coordinates. `colorsys.``rgb_to_hls`(*r*, *g*, *b*)Convert the color from RGB coordinates to HLS coordinates. `colorsys.``hls_to_rgb`(*h*, *l*, *s*)Convert the color from HLS coordinates to RGB coordinates. `colorsys.``rgb_to_hsv`(*r*, *g*, *b*)Convert the color from RGB coordinates to HSV coordinates. `colorsys.``hsv_to_rgb`(*h*, *s*, *v*)Convert the color from HSV coordinates to RGB coordinates. 示例: ``` >>> import colorsys >>> colorsys.rgb_to_hsv(0.2, 0.4, 0.4) (0.5, 0.5, 0.4) >>> colorsys.hsv_to_rgb(0.5, 0.5, 0.4) (0.2, 0.4, 0.4) ``` ### 导航 - [索引](../genindex.xhtml "总目录") - [模块](../py-modindex.xhtml "Python 模块索引") | - [下一页](imghdr.xhtml "imghdr --- 推测图像类型") | - [上一页](chunk.xhtml "chunk --- Read IFF chunked data") | - ![](https://box.kancloud.cn/a721fc7ec672275e257bbbfde49a4d4e_16x16.png) - [Python](https://www.python.org/) » - zh\_CN 3.7.3 [文档](../index.xhtml) » - [Python 标准库](index.xhtml) » - [多媒体服务](mm.xhtml) » - $('.inline-search').show(0); | © [版权所有](../copyright.xhtml) 2001-2019, Python Software Foundation. Python 软件基金会是一个非盈利组织。 [请捐助。](https://www.python.org/psf/donations/) 最后更新于 5月 21, 2019. [发现了问题](../bugs.xhtml)? 使用[Sphinx](http://sphinx.pocoo.org/)1.8.4 创建。