python学习——fnmatch
来源:互联网 发布:特朗普 中美关系 知乎 编辑:程序博客网 时间:2024/05/16 13:51
fnmatch 模块使用模式来匹配文件名
>>> from fnmatch import fnmatch, fnmatchcase>>> fnmatch('foo.txt', '*.txt')True>>> fnmatch('foo.txt', '?oo.txt')True>>> fnmatch('Dat45.csv', 'Dat[0-9]*')True>>> names = ['Dat1.csv', 'Dat2.csv', 'config.ini', 'foo.py']>>> [name for name in names if fnmatch(name, 'Dat*.csv')]['Dat1.csv', 'Dat2.csv']>>>
addresses = [ {'address':'5412 N CLARK', 'date': '07/01/2012'}, {'address':'5148 N CLARK', 'date': '07/04/2012'}, {'address':'5800 E 58TH', 'date': '07/02/2012'}, {'address':'2122 N CLARK', 'date': '07/03/2012'}, {'address':'5645 N RAVENSWOOD', 'date': '07/02/2012'}, {'address':'1060 W ADDISON', 'date': '07/02/2012'}, {'address':'4801 N BROADWAY', 'date': '07/01/2012'}, {'address':'1039 W GRANVILLE', 'date': '07/04/2012'},]>>> from fnmatch import fnmatchcase>>> [addr for addr in addresses if fnmatchcase(addr, '* ST')]['5412 N CLARK ST', '1060 W ADDISON ST', '2122 N CLARK ST']>>> [addr for addr in addresses if fnmatchcase(addr, '54[0-9][0-9] *CLARK*')]['5412 N CLARK ST']>>>
0 0
- python学习——fnmatch
- Python fnmatch — Unix filename pattern matching
- python -- fnmatch
- python fnmatch
- python fnmatch模块使用
- Python fnmatch 模块
- fnmatch
- fnmatch
- fnmatch
- 支持通配符的字符串比较——POSIX函数fnmatch
- Python 模糊匹配:glob, re, fnmatch
- python glob fnmatch 用于文件查找操作
- python标准库之fnmatch,dis,timeit
- Python: fnmatch模块 (Unix B-Shell通配符的文件名匹配)
- Python递归查找文件(os.path, fnmatch,glob)
- Python递归查找文件(os.walk, os.path, fnmatch)
- fnmatch.h
- fnmatch函数
- 关于mysql中文乱码问题的解决
- Android 进程和线程
- Android Fragment 真正的完全解析(下)
- JSON数据提取的基本方法-2015年9月14日
- android animation参数
- python学习——fnmatch
- malloc/free 与new/delete对比
- 【读书笔记】iOS-内存管理
- 模板方法模式(Template Method)
- 批处理
- informix之二
- 微PE工具箱v1.0 维护版本64位(0913)
- 图解Android - Zygote, System Server 启动分析
- 用AttributedString,来制作简单地描边效果