ARTICLE DETAIL

资讯详情

深耕网站建设、视觉设计与SEO优化的一线实战洞察。

python3

python3
import os def traverse_files(path): # 遍历当前路径下的所有文件和文件夹 for item in os.listdir(path): # 拼接完整路径 item_path = os.path.join(path, item) if os.path.isfile(item_path): # 是文件则输出路径 print("文件:", item_path) elif os.path.isdir(item_path): # 是文件夹则递归进入 traverse_files(item_path)
返回列表