Created
June 13, 2014 03:12
-
-
Save y-ogi/4541dd5751faa3277792 to your computer and use it in GitHub Desktop.
Python script for converting html color code to rgb
This file contains 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
import re | |
import sys | |
import optparse | |
def main(color): | |
print "R:%d G:%d B:%d" % tuple([int(x, 16) for x in re.findall('[a-fA-F0-9]{2}', color[1:] if color[0] == '#' else color)]) | |
if __name__ == '__main__': | |
usage = "Usage: %prog code" | |
parser = optparse.OptionParser(usage) | |
(options, args) = parser.parse_args() | |
if not args: | |
parser.error("required code") | |
parser.print_help() | |
exit(1) | |
main(args[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment