python集合输出_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']

递归输出文件夹下的所有文件的名称(转自 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 练习 把一个文件夹下的&period;java文件复制到另一个文件夹下的&period;txt文件

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

读取指定文件夹下的全部文件,可通过正则进行过滤,返回文件路径数组 -- 基于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 ...

Java——用程序编译一个文件夹下所有java文件到另一个文件夹下

package com.java.test.a; import java.io.IOException; import java.util.ArrayList; import java.util.Ar ...

随机推荐

win7远程桌面恢复全屏状态快捷键

不同的电脑可能有不同的快捷键(有些笔记本电脑甚至没有相应的键值):①台式机:ctrl+alt+break 组合键.②CTRL+ALT+PAGEDOWN 组合键.③有的笔记本没有break键,可以尝试加 ...

&period;NET面试必备(整理)

1.简述 private. protected. public. internal 修饰符的访问权限. private : 私有成员, 在类的内部才可以访问.public : 公共成员,完全公开,没有 ...

logstash学习2

从geoip字段取location的longitude字段 [geoip][location][0] 支持变量内插 "the longitude is %{[geoip][location] ...

意外的节点类型 Element。只能在简单内容或空内容上调用 ReadElementString 方法

问题出现的情景: 在调用携程团购接口时,需要把获取的xml字符串反序列化实体对象,出现了这个错误. 详情: 在对xml文档有这样一条语句“

boost的并发库

thread: http://www.boost.org/doc/libs/1_61_0/libs/thread/ asio: http://www.boost.org/doc/libs/1_61_0 ...

【简单并查集】Farm Irrigation

Farm Irrigation Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Tot ...

C&num; 开发系列&lpar;三&rpar;

参考:http://stackoverflow.com/questions/11248935/passing-values-to-a-put-json-request-in-c-sharp 发送htt ...

Keras 获取中间某一层输出

1.使用函数模型API,新建一个model,将输入和输出定义为原来的model的输入和想要的那一层的输出,然后重新进行predict. #coding=utf-8 import seaborn as ...

PHP多进程实例

PHP创建多进程需要使用到pcntl模块 在编译时加上--enable-pcntl打开进程控制支持,不是Unix类系统不支持此模块 php官网介绍http://php.net/manual/zh/bo ...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值