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设计】。

相关文章

利用Anaconda完美解决Python 2与python 3的共存问题

前言 现在Python3 被越来越多的开发者所接受,同时让人尴尬的是很多遗留的老系统依旧运行在 Python2 的环境中,因此有时你不得不同时在两个版本中进行开发,调试。 如何在系统中同...

Flask模拟实现CSRF攻击的方法

Flask模拟实现CSRF攻击的方法

CSRF CSRF全拼为Cross Site Request Forgery,译为跨站请求伪造。 CSRF指攻击者盗用了你的身份,以你的名义发送恶意请求。 包括:以你名义发送邮件,发消息...

在vscode中配置python环境过程解析

在vscode中配置python环境过程解析

1.安装vscode和python3.7(安装路径在:E:\Python\Python37); 2.打开vscode,在左下角点击设置图标选择setting,搜索python path,...

Python定时任务工具之APScheduler使用方式

APScheduler (advanceded python scheduler)是一款Python开发的定时任务工具。 文档地址 apscheduler.readthedoc...

pandas删除行删除列增加行增加列的实现

创建df: >>> df = pd.DataFrame(np.arange(16).reshape(4, 4), columns=list('ABCD'), ind...