[python's fnmatch&glob&os.listdir]

fnmatch:

  fnmatch只有4种special character,用于提供和shell中一样的文件名的匹配.

  

  For a literal match, wrap the meta-characters in brackets. For example, '[?]' matches the character '?'.

  主要函数有: fnmatch.fnmatch(), fnmatch.fnmatchcase(), fnmatch.filter(), fnmatch.translate()

  注意要点:

    1. '.'在fnmatch中只是一个普通的文件.

os.listdir:

  os.listdir提供类似于shell中的ls功能, 返回的列表只包含文件名, 默认不显示'.', '..'

glob:

  glob用于提供检索功能, 该功能的实现基于os.listdir & fnmatch. 返回的列表为cwd的相对路径.

  glob treats filenames beginning with a dot (.) as special cases. ('.' & '..' 在glob中会被解释为相应的路径)

  主要函数: glob.glob(), glob.iglob()

  注意:

    If the directory contains files starting with . they won’t be matched by default. For example, consider a directory containing card.gif and .card.gif:

    

参考:

 1. http://docs.python.org/2.7/library/glob.html#module-glob

 2. http://docs.python.org/2.7/library/fnmatch.html#fnmatch.fnmatch

 3. http://docs.python.org/2.7/library/os.html

python's fnmatch&glob&os.listdir的更多相关文章

  1. Python使用os.listdir()函数来得目录内容的介绍

    Python编程语言是计算机语言中常用的语言,以下的文章就是介绍在Python编程语言中使用os.listdir()函数来获得目录中的相关内容的介绍,如果你对其相关的实际操作有兴趣的话,你就可以观看以 ...

  2. Python:模块学习——os模块

    os模块提供了多个访问操作系统服务的功能 os模块中一些重要的函数和变量 os.name 显示当前使用平台 os.getcwd() 显示当前Python脚本工作路径 os.listdir('dirna ...

  3. 【转】Python模块学习 - fnmatch & glob

    [转]Python模块学习 - fnmatch & glob 介绍 fnmatch 和 glob 模块都是用来做字符串匹配文件名的标准库. fnmatch模块 大部分情况下使用字符串匹配查找特 ...

  4. Python模块学习 - fnmatch & glob

    介绍 fnmatch 和 glob 模块都是用来做字符串匹配文件名的标准库. fnmatch模块 大部分情况下使用字符串匹配查找特定的文件就能满足需求,如果需要更加灵活的字符串匹配,就没有办法了,这里 ...

  5. os模块、文件压缩 、匹配文件后缀名:fnmatch glob

    一.os模块 os模块:是python是系统交互的模块 import os # 0平台信息的一些操作 python是夸平台的,所以内部兼容了不同的平台 1. os.name # 操作系统 nt是win ...

  6. python fnmatch & glob

    1,转载:Python模块学习 - fnmatch & glob - Dahlhin - 博客园 (cnblogs.com) 介绍 fnmatch 和 glob 模块都是用来做字符串匹配文件名 ...

  7. Python使用os.listdir()函数来获得目录中的内容

    摘自:http://it.100xuexi.com/view/otdetail/20130423/057606dc-7ad1-47e4-8ea6-0cf75f514837.html   1.在Pyth ...

  8. python中的os.listdir()函数

    os.listdir() 方法用于返回指定的文件夹包含的文件或文件夹的名字的列表.这个列表以字母顺序. 它不包括 '.' 和'..' 即使它在文件夹中. 只支持在 Unix, Windows 下使用. ...

  9. python使用os.listdir和os.walk获得文件的路径

    python使用os.listdir和os.walk获得文件的路径   目录 情况1:在一个目录下面只有文件,没有文件夹,这个时候可以使用os.listdir 情况2:递归的情况,一个目录下面既有目录 ...

随机推荐

  1. drone 学习六 发布部署&&集成私有容器仓库&&构建代码s3 保存

    备注:      需要进行drone 以及gitlab 环境的配置,可以参考相关资料   1. 参考项目 https://github.com/rongfengliang/drone-appdemo ...

  2. gradle asciidoc 使用

    备注:    次文档参考github 例子   1.环境准备 node npm (yarn) java KindleGen 备注: 具体的安装可以参考网上相关文档,KindleGen 下载地址:htt ...

  3. pthread中读写锁

    读写锁很像一个互斥量,他阻止多个线程同时修改共享数据的另一种方法,区分不同互斥量的是他是分读数据和写数据,一个读写锁允许同时多个线程读数据,只要他们不修改数据. 只要没有写模式下的加锁,任意线程都可以 ...

  4. torcs代码

    /** Info returned by driver during the race */ typedef struct { tdble steer; /**< Steer command [ ...

  5. cocos2d js 利用texture packer生成sprite

    cc.spriteFrameCache.addSpriteFrames(res.winLose_plist,res.winLose_png); var frame = cc.spriteFrameCa ...

  6. MongoDB在windows平台分片集群部署

    本文转载自:https://www.cnblogs.com/hx764208769/p/4260177.html 前言-为什么我要使用mongodb 最近我公司要开发一个日志系统,这个日志系统包括很多 ...

  7. (转)Inno Setup入门(二十二)——Inno Setup类参考(8)

    本文转载自:http://blog.csdn.net/yushanddddfenghailin/article/details/17268473 列表框 列表框(ListBox)是Windows应用程 ...

  8. STM32=LWIP

    https://blog.csdn.net/zouw96/article/details/8443141

  9. git 绑定远程仓方法

    第1步:创建SSH Key.在用户主目录下,看看有没有.ssh目录,如果有,再看看这个目录下有没有id_rsa和id_rsa.pub这两个文件,如果已经有了,可直接跳到下一步.如果没有,打开Shell ...

  10. 获取响应里面的cookie的方法

    使用方法: R.cookies.get_dict()   获取响应返回的cookies