Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # RGB2Hex_and_Hex2RGB.py
- def hex_to_rgb(value):
- value = value[1:]
- lv = len(value)
- return tuple(int(value[i:i + lv // 3], 16) for i in range(0, lv, lv // 3))
- def rgb_to_hex(rgb):
- return '#%02x%02x%02x' % rgb
- print hex_to_rgb("#ffffff") # (255, 255, 255)
- print rgb_to_hex((255, 255, 255)) # '#ffffff'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement