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的更多相关文章

  1. 递归输出文件夹下的所有文件的名称(转自 MSDN)

    问题:如何输出给定文件夹目录下面的所有文件的名称? C#代码: using System; using System.IO; namespace MyTest { public class Progr ...

  2. 用Java实现将多级文件夹下的所有文件统一放到一个文件夹中

    每次下了电影(男生懂得呦),每部电影都放在一个单独的文件夹里,看的时候很是不方便啊,一直重复着进入文件夹.后退,再进.再退的操作,而手动把这些电影全部复制出来又太繁琐.因此为了解决这个问题,用IO写了 ...

  3. Java遍历一个文件夹下的全部文件

    Java工具中为我们提供了一个用于管理文件系统的类,这个类就是File类,File类与其它流类不同的是,流类关心的是文件的内容.而File类关心的是磁盘上文件的存储. 一,File类有多个构造器,经常 ...

  4. C# 输出文件夹下的所有文件

    问题:如何输出给定文件夹目录下面的所有文件的名称? C#代码: using System; using System.IO; namespace MyTest { public class Progr ...

  5. php 遍历一个文件夹下的所有文件和子文件

    php 遍历一个文件夹下的所有文件和子文件 <?php /** * 将读取到的目录以数组的形式展现出来 * @return array * opendir() 函数打开一个目录句柄,可由 clo ...

  6. Java基础面试操作题: File IO 文件过滤器FileFilter 练习 把一个文件夹下的.java文件复制到另一个文件夹下的.txt文件

    package com.swift; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File ...

  7. python删除某一文件夹下的重复文件

    #2022-10-28 import hashlib import os import time def getmd5(filename): """ 获取文件 md5 码 ...

  8. 读取指定文件夹下的全部文件,可通过正则进行过滤,返回文件路径数组 -- 基于node的一个函数

    var fs = require('fs'); // 模板文件夹路径 var templateDirectory = '../src'; //相对于当前文件的相对路径 //var templateDi ...

  9. 读取某文件夹下所有excel文件 python

    import os import pandas as pd from sklearn import linear_model path = r'D:\新数据\每日收益率' filenames = os ...

随机推荐

  1. Ubuntu18安装Pycharm时遇到的几个问题

    今天给电脑安装了Ubuntu18.04,安装了一些基础软件. 这里是Ubuntu安装Pycharm的一些问题: 1.安装Pycharm. 首先需要到Pycharm官网进行下载安装包,由于我的是Ubun ...

  2. Angular+Ionic+RSA实现后端加密前端解密功能

    因业务需要,需要给android应用安装证书,通过读取证书文件内容实现某些功能的控制: 流程:后台通过publicKey对指定内容的文件进行加密,生成文件共客户下载,客户下载后选择该证书文件读取到应用 ...

  3. mysqldump 备份数据和恢复

    命令行下具体用法如下:  mysqldump -u用戶名 -p密码 -d 数据库名 表名 > 脚本名; 一.导出数据: 导出整个数据库结构和数据mysqldump -h localhost -u ...

  4. 线程——自定义多线程task

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  5. python学习之 getattr vs __get__ vs __getattr __ vs __getattribute__ vs __getitem__

    1. getattr.setattr.hasattr getattr比较常用,与setattr和hasattr一起出现,他们也是最容易理解的,下面是他的用法: class Profile(): nam ...

  6. node的应用场景

    I/O密集型 I/O密集的优势主要在于Node利用事件循环的处理能力,而不是启动每一个线程为每一个请求服务,资源占用极少. 是否不擅长CPU密集型业务 换一个角度,在CPU密集的应用场景中,Node是 ...

  7. Redis 简介与命令操作

    redis 是 key-value 的数据,所以每个数据都是一个键值对,键的类型是字符串: 值的类型分为五种:string.hash.list.set(集合).zset(有序集合). 数据操作的全部命 ...

  8. Oracle GoldenGate微服务架构的服务Shell脚本

    Oracle GoldenGate微服务架构的/etc/init.d下的OracleGoldenGate服务Shell脚本: #!/bin/sh # # Oracle GoldenGate Servi ...

  9. [Kubernetes]说说 Service 与 Ingress

    在 Kubernetes 中, Service 有三种对外暴露的方法,但是由于每个 Service 都要有一个负载均衡的服务,所以采用 Service 的话,会造成既浪费成本又高的现象.对于用户来说, ...

  10. python学习第32天

    # 使用模块操作进程# multiprocessing 一个多元化的进程模块# multiple 多元化 processing 进程 # 涵盖了和进程相关的几乎所有的内容# Process类 帮助你启 ...