方法1:
import os
for dirpath, dirnames, filenames in os.walk('目标文件夹地址'):
file_counts = len(filenames)
print(file_counts)
方法2:
import os
file_count = 0
for dirpath, dirnames, filenames in os.walk('目标文件夹地址'):
for file in filenames:
file_count = file_count + 1
print(file_count)
版权声明:本文为weixin_45465214原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。