Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- import sys
- PATH = sys.argv[1]
- pat = re.compile(r"#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})")
- with open(PATH, 'r') as content_file:
- content = content_file.read()
- matches = re.findall(pat, content)
- matches = [x.upper() for x in matches] # ignoring case
- matches = list(set(matches)) # removing duplicates
- if not matches:
- print("No hex colors found")
- else:
- for m in matches:
- print("#" + m)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement