python中,怎样统计一个文件夹使用的磁盘空间
1个回答
展开全部
以下代码调试通过:
import os
count = 0
path = r'/Users/mfhj-dz-001-119/Downloads'
for root, dirs, files in os.walk(path):
#print files
fileLength = len(files)
if fileLength != 0:
count = count + fileLength
print "The number of files under <%s> is: %d" %(path,count)
import os
count = 0
path = r'/Users/mfhj-dz-001-119/Downloads'
for root, dirs, files in os.walk(path):
#print files
fileLength = len(files)
if fileLength != 0:
count = count + fileLength
print "The number of files under <%s> is: %d" %(path,count)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询