Pyhthon计算文件夹大小

Posted wengshaohang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Pyhthon计算文件夹大小相关的知识,希望对你有一定的参考价值。

 

 技术图片

不使用递归
import
os from os.path import join, getsize def getdirsize(dir): size = 0 for root, dirs, files in os.walk(dir): size += sum([getsize(join(root, name)) for name in files]) return size size = getdirsize(rD:python_code) print(There are %.3f % (size / 1024 / 1024), Mbytes in D:python_code)

以上是关于Pyhthon计算文件夹大小的主要内容,如果未能解决你的问题,请参考以下文章