import os
import os.path
A_server_photo_folder = 'C:/picture' #文件夹路径
def depth_first(path): # 深度优先遍历文件夹,栈,先进后出,先找到最深的,再弹出来,消耗内存
for i in os.listdir(path):
child = os.path.join(path, i)
if os.path.isdir(child):
depth_first(child)
else:
print(child)
depth_first(A_server_photo_folder)
Python 遍历文件夹中的所有文件,并打印所在的路径
最新推荐文章于 2024-05-19 23:31:32 发布