# -*- coding: utf-8 -*- import os.path import os list = os.listdir() print(os.getcwd()) txtnumber =0 pngnumber =0 pynumber= 0 docxnumber= 0 filenumber =0 dict= {'.txt':txtnumber,'.png':pngnumber,'.py':pynumber,'.docx':docxnumber,'文件夹':filenumber} for file in list: (name,extension)= os.path.splitext(file) if extension =='.txt': txtnumber+= 1 if extension =='.png': pngnumber+= 1 if extension =='.py': pynumber+= 1 if extension =='.docx': docxnumber+= 1 if extension =='.txt': txtnumber+= 1 if extension =='': dict['文件夹']+= 1 for name in dict.keys(): print('该文件夹下共有类型为【%s】的文件%s个&#
编写一个程序,统计当前文件夹下每个文件类型的文件数
最新推荐文章于 2024-04-23 23:00:42 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)