请教一下大神如何用python读取图片的txt标签内容并将图片及对应标签移动至指定文件夹
2018-09-11 · 知道合伙人互联网行家
关注
展开全部
import os
def search(s, path=os.path.abspath('.')):
for z in os.listdir(path):
if os.path.isdir(path + os.path.sep + z):
print('Currnet:', path)
path2 = os.path.join(path, z)
print('future:', path2)
search(s, path2)
elif os.path.isfile(path + os.path.sep + z):
if s in z:
print(os.path.join(path, z))
with open(path + os.path.sep + z, 'r') as fr:
with open('save.txt', 'a') as fw:
fw.write(path + '\t' + fr.read())
search('csv', '.')
def search(s, path=os.path.abspath('.')):
for z in os.listdir(path):
if os.path.isdir(path + os.path.sep + z):
print('Currnet:', path)
path2 = os.path.join(path, z)
print('future:', path2)
search(s, path2)
elif os.path.isfile(path + os.path.sep + z):
if s in z:
print(os.path.join(path, z))
with open(path + os.path.sep + z, 'r') as fr:
with open('save.txt', 'a') as fw:
fw.write(path + '\t' + fr.read())
search('csv', '.')
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询