美文网首页
python统计训练集下的图片个数

python统计训练集下的图片个数

作者: 小王子威威 | 来源:发表于2018-03-13 13:22 被阅读221次

参考:https://www.cnblogs.com/lovychen/p/5291673.html

-----------------------------------------------------------------------------------------------------

#统计 /home/dir/ 下的文件夹个数

import os

path ="home/dir"

count = 0

for fn in os.listdir(path): #fn 表示的是文件名

        count = count+1

print count

-----------------------------------------------------------------------------------------------------

获取文件夹下的文件的个数:

import os

path = os.getcwd()    #获取当前路径

count = 0

for root,dirs,files in os.walk(path):    #遍历统计

      for each in files:

            count += 1  #统计文件夹下文件个数

print count              #输出结果

-----------------------------------------------------------------------------------------------------

相关文章

网友评论

      本文标题:python统计训练集下的图片个数

      本文链接:https://www.haomeiwen.com/subject/erkzfftx.html