gyn

Win32下的Perl,无用的select,停滞的Tk,结束吧....

获取文件夹大小的python代码

可能是太简单的缘故,在google中查询不到,所以贴一下免得忘记了:
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'

posted on 2007-11-01 14:25 gyn_tadao 阅读(5128) 评论(0)  编辑 收藏 引用 所属分类: Python

只有注册用户登录后才能发表评论。
<2007年11月>
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678

导航

统计

常用链接

留言簿(15)

随笔分类(126)

随笔档案(108)

相册

搜索

最新评论

阅读排行榜

评论排行榜