# coding:utf-8
import os
path = "C:\\Users\\15527\\Desktop\\demo"
def get_file(path, file_list):
if os.path.isfile(path):
file_list.append(path)
elif os.path.isdir(path):
for item in os.listdir(path):
item_path = os.path.join(path, item)
get_file(item_path, file_list)
return file_list
list = get_file(path, [])
for file in list:
print(file)
python遍历文件夹及其子文件夹中的所有文件
猜你喜欢
转载自blog.csdn.net/weixin_44857400/article/details/107371254
今日推荐
周排行