提取文件并另存为
作者:互联网
import os from PIL import Image as img i=0 # j=1399 for root, dirs, files in os.walk('D:\pro/tuu',topdown=False): for dir in dirs: i += 1 for file in os.listdir(os.path.join(root,dir)): path=os.path.join(root,dir) w=img.open(os.path.join(path,'label.png')) x=dir.split('_') q=x[0]+'_mask' w.save('D:\pro\crack\新建文件夹 (2)/new5/%s.png'%(q)) # # for root, dirs, files in os.walk('D:\pro\Positive2',topdown=False): # for dir in dirs: # j += 1 # for file in os.listdir(os.path.join(root,dir)): # path=os.path.join(root,dir) # w=img.open(os.path.join(path,'img.png')) # w.save('D:\pro/new4/%d.png'%(j))ttiqu
标签:文件,提取,img,另存为,join,root,path,os,dir 来源: https://blog.csdn.net/m0_51103818/article/details/121467233