import os
print(os.path.getsize("guide_to_python.txt")) #os.path.getsize 获取单个文件的大小
sum_size = 0
for file in os.listdir("../001-010"):
if os.path.isfile(file): #判断是文件还是目录
sum_size += os.path.getsize(file)
print("all size of dir: ",sum_size/1000)
python练习题015:统计目录下所有文件大小
最新推荐文章于 2024-05-01 06:27:07 发布