对照文本文件提取文件工具(正在修改版)
import os
import shutil
path = 'C:/Users/Administrator/Desktop/列表.txt'
root = 'C:/Users/Administrator/Desktop/文件夹1'
root1 ='C:/Users/Administrator/Desktop/文件夹2'
with open(path,encoding="utf-8") as obj:
words = obj.readlines()
for word in words:
for dirpath,dirname,filenames in os.walk(root):
for filename in filenames:
if word.strip == filename[0:-5]:
print(word.strip)
print(filename.split(".")[0])
shutil.copy(root + "/" + filename,root1)