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单核
# 单位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单核