python批量输出指定文件夹文件数量

python批量输出指定文件夹文件数量

import os
n_list=[11,12,13,14,15,50]
n1_list=["tiktok","youtube","ins"]
n2_list=["i","b","r"]
for n in n_list:
    for n1 in n1_list:
        for n2 in n2_list:
            path=f"//192.168.xx.xx/config/lily/{n1}/{n2}/a{n}"#路径可随意更改
            try:
                files = os.listdir(path)  # 读入文件夹
                num = len(files)  # 统计文件夹中的文件个数
                print(num,"文件夹:",path)  # 打印文件个数
            except:
                print("出错")

 

posted @ 2022-01-20 16:55  野猫炫  阅读(224)  评论(0编辑  收藏  举报