# -*- coding: utf-8 -*- # author:baoshan import os dirname = r‘D:\0.shenma\01.聊城资料\01.数据资料\02.聊城年鉴数据\2017年鉴‘ filename = ".xls" result = [] def search(dirname=dirname, filename=""): for item in os.listdir(dirname): item_path = os.path.join(dirname, item) if os.path.isdir(item_path): search(item_path, filename) elif os.path.isfile(item_path): if filename in item: global result result.append(item_path +";") print(item_path+";") if __name__ == ‘__main__‘: search(dirname, filename)
转自:https://www.cnblogs.com/hyacinthwyd/p/8997917.html
谢谢!
原文地址:https://www.cnblogs.com/zhzhang/p/11605345.html
时间: 2024-10-07 15:30:50