Skip to content

Instantly share code, notes, and snippets.

@y-ogi
Created June 13, 2014 03:12
Show Gist options
  • Save y-ogi/4541dd5751faa3277792 to your computer and use it in GitHub Desktop.
Save y-ogi/4541dd5751faa3277792 to your computer and use it in GitHub Desktop.
Python script for converting html color code to rgb
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