返回目录和子目录中的文件数 [英] Return number of files in directory and subdirectory
本文介绍了返回目录和子目录中的文件数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试创建一个函数,该函数返回找到的目录及其子目录的文件数.只需要入门帮助
Trying to create a function that returns the # of files found a directory and its subdirectories. Just need help getting started
推荐答案
One - liner
One - liner
import os
cpt = sum([len(files) for r, d, files in os.walk("G:\CS\PYTHONPROJECTS")])
这篇关于返回目录和子目录中的文件数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文