请教一下大神如何用python读取图片的txt标签内容并将图片及对应标签移动至指定文件夹

Python021

请教一下大神如何用python读取图片的txt标签内容并将图片及对应标签移动至指定文件夹,第1张

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', '.')

import os

drive = "D:\\"

for root, dirs, files in os.walk(drive):

if root == 'a':

print dirs

print files