提取存在的文件函数

def find_file(mypath,need_list):
      '遍历数据源文件夹,提取指定类型文件'
      find_list = []
      if len(need_list) == 0:
            return find_list
      
      for file_name in need_list:
            sname = os.listdir(mypath + 'data\\')
            flag = False
            for f in sname:
                  fname = os.path.splitext(f)
                  if (fname[0] == file_name) and (fname[-1] == '.xlsx'):
                        find_list.append(file_name)
      return find_list

猜你喜欢

转载自blog.csdn.net/lee2601/article/details/81084887
今日推荐