python3获取文件夹大小

# 单位byte   
def getdirsize(self,args): dir
= args.dir size = 0 for root, dirs, files in os.walk(dir): size += sum([getsize(join(root, name)) for name in files]) return size

 性能还挺高,获取10G文件夹大小只需20s左右,我机器是1g单核

posted @ 2021-03-01 22:56  山上小和尚  阅读(303)  评论(0编辑  收藏  举报