代码如下:
def get_file_count(file_path):
"""获取指定文件夹下的文件数量"""
number = 0
for root,dirname,filenames in os.walk(file_path):
for filename in filenames:
# print(filename)
if os.path.splitext(filename)[1] == '.log':
number += 1
elif os.path.splitext(filename)[1] == '.html':
number += 1
return number