import os txt_path = 't1.txt' f = open(txt_path, mode='a', encoding='utf-8') def all_path(dirname): result = [] for maindir, subdir, file_name_list in os.walk(dirname): for filename in file_name_list: if '.jpg' in filename: result.append(filename) re