python读取相似文件并处理

来源:互联网 发布:c语言第四版答案完整版 编辑:程序博客网 时间:2024/06/08 05:58
http://blog.csdn.net/eddy_zheng/article/details/47312729#coding=utf-8'''使用函数os.dirlist()读取文件夹内的文件名字2015.08.06'''from os import listdir#将文件夹内的文件名读进列表mfilepath='C:\Users\Administrator\Desktop\mycode\cv-python-day13'filename_list=listdir(filepath)h=[]#可以同过简单后缀名判断,筛选出你所需要的文件(这里以.jpg为例)for filename in filename_list:#依次读入列表中的内容    if filename[-3:]=='jpg':#将读取文件名字的后三个字符与'jpg'匹对        h.append(x)#如果是'jpg'文件就添加进列表hprint h
0 0