Python统计文件夹下文件的个数

 
  
import os

print(len(os.listdir('./contents2')))
ls = os.listdir('./document_classification')
print(ls)
count = 0
for l in ls:
    ll = os.path.join('./document_classification', l)
    print(ll)
    count += len(os.listdir(ll))
    print(count)

你可能感兴趣的:(python,开发语言)