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 阅读(381) 评论(0)  编辑 收藏 引用 所属分类: Python



标题  
姓名  
主页
验证码 *
内容(提交失败后,可以通过“恢复上次提交”恢复刚刚提交的内容)
 
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
[使用Ctrl+Enter键可以直接提交]
 
相关链接:



<2008年12月>
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

导航

统计

常用链接

留言簿(3)

随笔分类(99)

随笔档案(82)

相册

搜索

最新评论

阅读排行榜

评论排行榜