Use the format operator %
:
>>> '#%02x%02x%02x' % (0, 128, 64)
'#008040'
Note that it won’t check bounds…
>>> '#%02x%02x%02x' % (0, -1, 9999)
'#00-1270f'
More Related Contents:
- OpenCV giving wrong color to colored images on loading
- Converting Hex to RGB value in Python
- HSV to RGB Color Conversion
- Calculate RGB value for a range of values to create heat map
- Convert hex string to int in Python
- OpenCV: Choosing HSV thresholds for color filtering
- Getting individual colors from a color map in matplotlib
- RGB Int to RGB – Python
- Convert bytes to bits in python
- Convert hex string to integer in Python
- How to convert an int to a hex string?
- Converting hex color to RGB and vice-versa
- Python 3.1.1 string to hex
- How to change the color of the axis, ticks and labels for a plot in matplotlib
- How to create python bytes object from long hex string?
- Python Matplotlib Boxplot Color
- Python – Find dominant/most common color in an image
- What’s 0xFF for in cv2.waitKey(1)?
- How to change ttk.progressBar color in python
- Convert hex color to RGB values in PHP
- Quickly getting the color of some pixels on the screen in Python on Windows 7
- matplotlib generic colormap from tab10
- How to find the RED color regions using OpenCV? [duplicate]
- Python 3: I am trying to find find all green pixels in an image by traversing all pixels using an np.array, but can’t get around index error
- Elegantly changing the color of a plot frame in matplotlib
- Change specific RGB color pixels to another color, in image file
- 2D grid data visualization in Python
- How to change the color of the axis, ticks and labels
- How to change the foreground or background colour of a selected cell in tkinter treeview?
- How do I convert hex to decimal in Python? [duplicate]