import csv
# 读取csv至字典
import os
import shutil
csvFile = open("label.csv", "r")
reader = csv.reader(csvFile)
# 建立空字典
result = {}
# def readname():
# filePath = 'D:\\PycharmProjects\\01python\\wethear'
# name = os.listdir(filePath)
# return name
'''
读取文件夹下所有文件名
'''
filePath = '/\\wethear'
name = os.listdir(filePath)
temppath = 'D:\\PycharmProjects\\01python\\wethear'
filePath1 = 'D:\\PycharmProjects\\01python\\0'
for item in reader:
# 忽略第一行
# if reader.line_num == 1:
# continue
#result[item[0]] = item[1]
#print(item[1])
if item[1] == '0':
for i in name:
#print(i)
if item[0]==i:
filePath = os.path.join(filePath,i)
#print("1111")
shutil.copy(filePath,filePath1)
filePath = temppath
csvFile.close()
#print(result.keys())
脚本1-读取csv文件-通过文件名,转移文件到另一个目录
最新推荐文章于 2022-08-30 17:54:30 发布