Python封装:实现输出一个文件夹下所有各个文件的地址存为列表集合内——Jason niu
def getAllImages(folder):
assert os.path.exists(folder)
assert os.path.isdir(folder)
imageList = os.listdir(folder)
imageList = [os.path.abspath(item) for item in imageList if os.path.isfile(os.path.join(folder, item))]
print(imageList[1])
return imageList
print (getAllImages(r"F:\\File_Python\\Python_example\\faceRecognition-master\\Original_picture\\Jason_niu"))
输出结果
读取成功
Jason_niu
F:\File_Python\Python_example\faceRecognition-master\Jason_niu (1).png
['F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (1).jpg', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (1).png', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (10).jpg', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (11).jpg', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (12).jpg', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (13).jpg', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (14).jpg', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (15).jpg', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (16).jpg', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (17).jpg', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (18).jpg', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (19).jpg', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (2).jpg', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (2).png', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (20).jpg', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (21).jpg', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (22).jpg', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (23).jpg', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (24).jpg', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (25).jpg', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (3).jpg', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (3).png', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (4).jpg', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (4).png', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (5).jpg', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (5).png', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (6).jpg', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (6).png', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (7).jpg', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (7).png', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (8).jpg', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (8).png', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (9).jpg', 'F:\\File_Python\\Python_example\\faceRecognition-master\\Jason_niu (9).png']
Python封装:实现输出一个文件夹下所有各个文件的地址存为列表集合内——Jason niu的更多相关文章
- 递归输出文件夹下的所有文件的名称(转自 MSDN)
问题:如何输出给定文件夹目录下面的所有文件的名称? C#代码: using System; using System.IO; namespace MyTest { public class Progr ...
- 用Java实现将多级文件夹下的所有文件统一放到一个文件夹中
每次下了电影(男生懂得呦),每部电影都放在一个单独的文件夹里,看的时候很是不方便啊,一直重复着进入文件夹.后退,再进.再退的操作,而手动把这些电影全部复制出来又太繁琐.因此为了解决这个问题,用IO写了 ...
- Java遍历一个文件夹下的全部文件
Java工具中为我们提供了一个用于管理文件系统的类,这个类就是File类,File类与其它流类不同的是,流类关心的是文件的内容.而File类关心的是磁盘上文件的存储. 一,File类有多个构造器,经常 ...
- C# 输出文件夹下的所有文件
问题:如何输出给定文件夹目录下面的所有文件的名称? C#代码: using System; using System.IO; namespace MyTest { public class Progr ...
- php 遍历一个文件夹下的所有文件和子文件
php 遍历一个文件夹下的所有文件和子文件 <?php /** * 将读取到的目录以数组的形式展现出来 * @return array * opendir() 函数打开一个目录句柄,可由 clo ...
- Java基础面试操作题: File IO 文件过滤器FileFilter 练习 把一个文件夹下的.java文件复制到另一个文件夹下的.txt文件
package com.swift; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File ...
- python删除某一文件夹下的重复文件
#2022-10-28 import hashlib import os import time def getmd5(filename): """ 获取文件 md5 码 ...
- 读取指定文件夹下的全部文件,可通过正则进行过滤,返回文件路径数组 -- 基于node的一个函数
var fs = require('fs'); // 模板文件夹路径 var templateDirectory = '../src'; //相对于当前文件的相对路径 //var templateDi ...
- 读取某文件夹下所有excel文件 python
import os import pandas as pd from sklearn import linear_model path = r'D:\新数据\每日收益率' filenames = os ...
随机推荐
- kubernetes包管理工具Helm安装
helm官方建议使用tls,首先生成证书. openssl genrsa -out ca.key.pem openssl req -key ca.key.pem -new -x509 -days -s ...
- 将Python3导出为exe程序
一.pyinstaller简介 Python是一个脚本语言,被解释器解释执行.它的发布方式: .py文件:对于开源项目或者源码没那么重要的,直接提供源码,需要使用者自行安装Python并且安装依赖的各 ...
- Java SE之快速失败(Fast-Fail)与快速安全(Fast-Safe)的区别[集合与多线程/增强For](彻底详解)
声明 特点:基于JDK源码进行分析. 研究费时费力,如需转载或摘要,请显著处注明出处,以尊重劳动研究成果:博客园 - https://www.cnblogs.com/johnnyzen/p/10547 ...
- luogu P5305 [GXOI/GZOI2019]旧词
传送门 先考虑\(k=1\),一个点的深度就是到根节点的路径上的点的个数,所以\(lca(x,y)\)的深度就是\(x\)和\(y\)到根路径的交集路径上的点的个数,那么对于一个询问,我们可以对每个点 ...
- HTTP协议 详解
前言 掌握HTTP协议是每一个开发者的基础,超详细的HTTP协议笔记 正文 HTTP协议格式总览 HTTP line HTTP Method(方法) 介绍了我们请求希望执行的操作类型. 方法有: GE ...
- istio环境搭建for macbook
首先需要搭建docker+k8s环境,如何搭建这里就不再赘述,可以自行搜索. 打开命令行,运行命令: curl -L https://git.io/getLatestIstio | ISTIO_VER ...
- python zip dict函数
1.zip函数 zip函数可以接受多个参数,返回的结果是列表,列表中的每一个元素是元组的数据类型,下面我们通过几个例子来学习zip函数的用法 1) list1 = [1,2,3] list2 = [4 ...
- 使用Perfect Player观看电视直播
Perfect Player下载地址: 官网 http://niklabs.com/ 去广告版本:链接: https://pan.baidu.com/s/1gevIdBghB6lB46vVyfQUWg ...
- (五)ORBSLAM关键帧的筛选和插入
ORBSLAM2的关键帧简介 图像插入频率过高会导致信息冗余度快速增加,而这些冗余的信息对系统的精度却十分有限,甚至没有提高,反而消耗了更多的计算资源.这等于吃力不讨好. 关键帧的目的在于,适当地降低 ...
- dotnet core使用开源组件FastHttpApi进行web应用开发(转)
FastHttpApi相对于asp.net mvc来说有着更轻量和性能上的优势,性能上面就不在这里介绍了(具体可查看 https://github.com/IKende/FastHttpApi). ...