Py学习  »  Python

如何计算特定目录中的文件数,而不扫描python中的子文件夹

Ratha • 5 年前 • 2096 次点击  

我试着喜欢;

 files = os.listdir(file_path)
    print(len(files)) <--gets counts of all files in subdirctory too
 for f in files:
  if (f.endswith('.xlsx')):
    print(count of *.clxs files)

我只需要在根目录中计算excel文件,在python中如何计算?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/46714
 
2096 次点击  
文章 [ 3 ]  |  最新文章 5 年前