源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

python 查找文件夹下所有文件 实现代码

  • 时间:2021-03-02 06:29 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:python 查找文件夹下所有文件 实现代码
[u]复制代码[/u] 代码如下:
def find_file_by_pattern(pattern='.*', base=".", circle=True): '''''查找给定文件夹下面所有 ''' re_file = re.compile(pattern) if base == ".": base = os.getcwd() final_file_list = [] print base cur_list = os.listdir(base) for item in cur_list: if item == ".svn": continue full_path = os.path.join(base, item) if full_path.endswith(".doc") or \ full_path.endswith(".bmp") or \ full_path.endswith(".wpt") or \ full_path.endswith(".dot"): continue # print full_path bfile = os.path.isfile(item) if os.path.isfile(full_path): if re_file.search(full_path): final_file_list.append(full_path) else: final_file_list += find_file_by_pattern(pattern, full_path) return final_file_list
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部