def findAllSmallJson(json_file, save_small_root):
big_dir, big_name = os.path.split(json_file)
big_not_suffix, big_suffix = os.path.splitext(big_name)
find_file_list = []
# 6319938267001088._1_19_136.jpg
small_name = big_not_suffix + '_\d' + '_\d' + '_\d' + big_suffix
small_all = list(paths.list_files(save_small_root, '.json'))
for small_file in small_all:
small_file_name = os.path.split(small_file)[1]
ret = re.findall(big_not_suffix+"_\d+_\d+_\d+" + big_suffix, small_file_name)
if ret:
find_file_list.append(os.path.join(save_small_root, ret[0]))
return find_file_list
python 正则查找文件名
最新推荐文章于 2022-08-09 22:40:23 发布