# 又学到了。。 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)
时间: 2024-12-29 13:47:27
# 又学到了。。 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)