求详细解释下python代码
defeachFile(filepath):count=0pathDir=os.listdir(filepath)forallDirinpathDir:child=os....
def eachFile(filepath):
count = 0
pathDir = os.listdir(filepath)
for allDir in pathDir:
child = os.path.join('%s%s' % (filepath,allDir))
write_child = os.path.join('%s%s' % (write_path,allDir))
img = load_img(child)
nul_num = re.findall(r"\d",child)
nul_num = int(nul_num[0])
x = img_to_array(img)
x = x.reshape((1,)+x.shape)
i = 0
for batch in datagen.flow(
x,
batch_size =1,
save_to_dir = write_path,
save_prefix = nul_num,save_format = 'jpeg'):
count += 1
i += 1
if i >= 10 :
break
return count 展开
count = 0
pathDir = os.listdir(filepath)
for allDir in pathDir:
child = os.path.join('%s%s' % (filepath,allDir))
write_child = os.path.join('%s%s' % (write_path,allDir))
img = load_img(child)
nul_num = re.findall(r"\d",child)
nul_num = int(nul_num[0])
x = img_to_array(img)
x = x.reshape((1,)+x.shape)
i = 0
for batch in datagen.flow(
x,
batch_size =1,
save_to_dir = write_path,
save_prefix = nul_num,save_format = 'jpeg'):
count += 1
i += 1
if i >= 10 :
break
return count 展开
1个回答
2018-02-02 · 百度知道合伙人官方认证企业
育知同创教育
1【专注:Python+人工智能|Java大数据|HTML5培训】 2【免费提供名师直播课堂、公开课及视频教程】 3【地址:北京市昌平区三旗百汇物美大卖场2层,微信公众号:yuzhitc】
向TA提问
关注
展开全部
这段代码的意思是循环查找目录下的图片文件,截取文件名中代数字的,重新保存到另外一个目录
追问
nul_num = re.findall(r"\d",child)
nul_num = int(nul_num[0])取第一个数字有什么意义
下面这两句话是什么意思
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询