diskwalk.py 399 B

12345678910111213141516
  1. # coding: utf-8
  2. __author__ = "lau.wenbo"
  3. import os,sys
  4. class diskwalk(object):
  5. def __init__(self, path):
  6. self.path = path
  7. def paths(self):
  8. path = self.path
  9. # 这里用了一个迭代器逻辑,防止所有数据塞内存爆掉
  10. path_collection = (os.path.join(root,fn) for root,dirs,files in os.walk(path) for fn in files)
  11. return path_collection