python 移动图片到另外一个文件夹的实例

yipeiwu_com6年前Python基础

如下所示:

# -*- coding:utf8 -*-
 
import os
import shutil
import numpy as np
import pandas as pd
path_img='C:/Users/49691/Desktop/数据集/test'
ls = os.listdir(path_img)
lenl=len(ls)
print(len(ls))
 
 
train_labels = pd.read_csv('C:/Users/49691/Desktop/数据集/b.csv')
train_labels.head()
labels = train_labels.invasive.values
name = train_labels.name.values
print(train_labels.shape,train_labels.shape[0],labels,name)
 
for i in range(lenl):
 #if i.find('testnan')!=-1:
 shutil.move(path_img+'/'+str(i) + ".jpg","C:/Users/49691/Desktop/数据集/test1/"+ str(name[i]) +".jpg")
 print(i,name[i])

以上这篇python 移动图片到另外一个文件夹的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

python中文件变化监控示例(watchdog)

在python中文件监控主要有两个库,一个是pyinotify ( https://github.com/seb-m/pyinotify/wiki ),一个是watchdog(http:...

常用python数据类型转换函数总结

1、chr(i)chr()函数返回ASCII码对应的字符串。复制代码 代码如下:>>> print chr(65)A>>> print chr(66)...

Python语法分析之字符串格式化

前序 There should be one - and preferably only one - obvious way to do it. ———— the Zen of Pyt...

Python Web框架Flask信号机制(signals)介绍

信号(signals) Flask信号(signals, or event hooking)允许特定的发送端通知订阅者发生了什么(既然知道发生了什么,那我们可以知道接下来该做什么了)。...

Python 实现训练集、测试集随机划分

Python 实现训练集、测试集随机划分

随机从列表中取出元素: import random dataSet = [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9], [10]...