使用python脚本对文件处理
使用python脚本对文件处理
import shutil import os os.mkdir('file_400') fr = open("list.txt") lines = fr.readlines() i = 0 fr_word = open('word.txt') lines_word =fr_word.readlines() for line in lines: line = line.strip('\n') #move needed file to new file shutil.copy('train_jpg/' + line,'file_400') #rename the needed file to os.rename('file_400/' + line,'file_400/' + lines_word[i].strip('\n') +'_'+ line ) i = i + 1