Advertisement
PikMike

Untitled

Jul 23rd, 2017
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. import os
  2. rdirs = {"D:/disk/Users/Mike/Documents", "D:/disk/Documents"}
  3.  
  4. exts = {}
  5.  
  6. for rootdir in rdirs:
  7.     for subdir, dirs, files in os.walk(rootdir):
  8.         for file in files:
  9.             ext = os.path.splitext(file)[1]
  10.             if (ext in exts):
  11.                 exts[ext] += 1
  12.             else:
  13.                 exts[ext] = 1
  14.  
  15. fn = {".cpp", ".py", ".java", ".c", ".pas"}
  16. res = 0
  17.  
  18. for ext in fn:
  19.     if (ext in exts):
  20.         res += exts[ext]
  21.         print(ext + ":", exts[ext])
  22.  
  23. print("---------")
  24. print(res)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement