Created
November 22, 2018 10:35
-
-
Save DarthJahus/2b29b395357961ffe58f3fcb388e9614 to your computer and use it in GitHub Desktop.
Simple Python script to convert hexadecimal color codes to RGB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Simple Python script to convert hexadecimal color codes to RGB | |
Jahus, 2018-11-21 | |
""" | |
while True: | |
try: | |
print("Hex?") | |
s = input() | |
s = s.replace('#', '').replace('0x', '') | |
h = int(s, 16) | |
b = h & 0xFF | |
g = (h & 0xFF00) >> 8 | |
r = (h & 0xFF0000) >> 16 | |
print("R: %s\nG: %s\nB: %s" % (r, g, b)) | |
except KeyboardInterrupt: | |
exit() | |
except: | |
print("Wrong format. Try again.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment