1 from imutils import paths 2 pathss = ‘D:\\pycode\\learn\\data\\‘ 3 4 def get_imgPath(path): 5 imagePaths = sorted(list(paths.list_images(path))) 6 #print(imagePaths) 7 i = 0 8 for img_name in imagePaths: 9 # print(img_name) 10 11 with open("path.txt", "a") as f: 12 i += 1 13 print(i) 14 f.write(img_name) 15 f.write(‘\n‘) 16 return imagePaths 17 18 get_imgPath(pathss)
写了一个工具函数很开心