1. 程式人生 > >文件夾內自動圖片遍歷

文件夾內自動圖片遍歷

color gpo 遍歷 txt int paths .com 分享圖片 write

 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)

技術分享圖片

寫了一個工具函數很開心

文件夾內自動圖片遍歷