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 ...
随机推荐
- Exp3 免杀原理与实践
一.实验过程 1.编码器 (1)使用msf编码器,直接生成meterpreter可执行文件(跟Exp2中生成backdoor.exe的过程一样,生成后门文件),送到Virscan.VirusTotal ...
- [译]ASP.NET Core揭秘 - Razor Pages
原文 什么是Razor Pages? Razor pages是ASP.NET Core 2.0的新特性,它被设计用来更快的开发页面,比传统的MVC模式更便捷. 创建项目 为了使用Razor Pages ...
- string与number转换
数字变字符串:str+'' 字符串变数字:str-0
- HTTPS加密那点事-对称、非对称加密、数字证书
转自:[漫画]https 加密那点事 首先,HTTP协议的缺点:没有对数据进行加密,都是明文传输的.如果要改进这种明文传输的协议,该如何做呢? 对称加密: 在每次发送真实数据之前,服务器先生成一把密钥 ...
- HDU-1398 Square Coins(生成函数)
题意 与$hdu1028$类似,只不过可用的数字都是平方数. 思路 类似的思路,注意下细节. 代码 #include <bits/stdc++.h> #define DBG(x) cerr ...
- 带@的css语法,你知道多少?
前言 css的顶层样式表由两种规则组成的规则列表构成,一种称为at—rule规则,也就是at规则,另一种是qualified rule,也就是普通规则.今天就学习一下at规则 正文 @charset ...
- A Discriminative Feature Learning Approach for Deep Face Recognition
url: https://kpzhang93.github.io/papers/eccv2016.pdf year: ECCV2016 abstract 对于人脸识别任务来说, 网络学习到的特征具有判 ...
- 使用docker中mysql镜像
1.拉取mysql镜像 docker pull mysql:5.6 2.运行mysql的镜像生成一个正在运行的容器,可以通过docker contain ls得到容器的id信息 docker run ...
- Nginx:Linux下安装Nginx与配置
准备目录 [root@sijizhen ~]# mkdir /usr/local/nginx [root@sijizhen ~]# cd /usr/local/nginx/ 下载 1.Nginx,在h ...
- vs/windows程序找不到入口点cuvidGetDecodeStatus于AppDecGL.exe动态链接库上
解决方法:这个问题的原因是由于使用的英伟达显卡驱动版本不够新,更新显卡驱动即可. 找了一个多月的原因,终于知道起源了.最终问题还是出在了nvcuvid.lib/.dll上面.通过分析vs调试信息可以得 ...