python获取文件夹大小的代码

2015-01-23 0 464
python获取文件夹大小的代码
import os
from os.path import join, getsize
 
def getdirsize(dir):
   size = 0L
   for root, dirs, files in os.walk(dir):
      size += sum([getsize(join(root, name)) for name in files])
   return size
 
if __name__ == '__main__':
   filesize = getdirsize(r'c:\windows')
   print 'There are %.3f' % (size/1024/1024), 'Mbytes in c:\\windows'

遇见资源网 python python获取文件夹大小的代码 http://www.ox520.com/15065.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务