Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. import re
  2. import sys
  3.  
  4. PATH = sys.argv[1]
  5.  
  6. pat = re.compile(r"#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})")
  7.  
  8. with open(PATH, 'r') as content_file:
  9. content = content_file.read()
  10. matches = re.findall(pat, content)
  11.  
  12.  
  13. matches = [x.upper() for x in matches] # ignoring case
  14. matches = list(set(matches)) # removing duplicates
  15. if not matches:
  16. print("No hex colors found")
  17. else:
  18. for m in matches:
  19. print("#" + m)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement