os.walk 查看目录大小

# 又学到了。。
def Test1(rootDir):
    tmp_lst = []
    for root,dirs,file in os.walk(rootDir):
        for f in file:
            tmp_lst.append(root+os.sep+f)
    size = 0
    for i in tmp_lst:
        size += os.stat(i).st_size
    return size

r = Test1('d:\\test')
print(r)

 

posted @ 2016-07-16 00:13  Cool_King  阅读(145)  评论(0编辑  收藏  举报