要实现的fnmatch分支**

pywildcard的Python项目详细描述


通配符

这个库是fnmatch的分支 (https://docs.python.org/2/library/fnmatch.html)来实现**

PypiDownloads

所有文档都与fnmatch相同,除了**现在是 ***只影响特定目录

https://docs.python.org/2/library/fnmatch.html

安装

pip install pywildcard

链接pypi:https://pypi.python.org/pypi/pywildcard

示例

importpywildcarddirs=['hello/world.py','hello/world.pyc','hello/world/other/folder/example.py']pywildcard.filter(dirs,'hello/*')# ['hello/world.py', 'hello/world.pyc']pywildcard.filter(dirs,'hello/*.py')# ['hello/world.py']pywildcard.filter(dirs,'hello/**')# ['hello/world.py', 'hello/world.pyc', 'hello/world/other/folder/example.py']pywildcard.filter(dirs,'hello/**.py')# ['hello/world.py', 'hello/world/other/folder/example.py']

区分fnmatch&pywildcard

fnmatch

importreimportfnmatchurls=['example/l1/l2/test3-1.py','example/l1/test2-1.py','example/l1/test2-2.py','example/l1/l2/l3/test4-1.py']regex=fnmatch.translate('example/*')# 'example\\/.*\\Z(?ms)'re.findall(regex,"\n".join(urls))# return ['example/l1/l2/test3-1.py\nexample/l1/test2-1.py\nexample/l1/test2-2.py\nexample/l1/l2/l3/test4-1.py']

通配符

importreimportpywildcardurls=['example/l1/l2/test3-1.py','example/l1/test2-1.py','example/l1/test2-2.py','example/l1/l2/l3/test4-1.py']regex=pywildcard.translate('example/**')# 'example/.*?$(?ms)'re.findall(regex,"\n".join(urls))# return ['example/l1/l2/test3-1.py',#         'example/l1/test2-1.py',#         'example/l1/test2-2.py',#         'example/l1/l2/l3/test4-1.py']

运行单元测试

``` bash查看git存储库。Git克隆 git@github.com:agalera/python-wildcard.git输入目录。光盘 python通配符如果尚未安装pytest,请安装pytest。皮普 安装pytest运行测试pytest

更改日志

1.0.8(2015-11-26)

  • 更新readme.md

1.0.7(2015-11-25)

  • 添加文档

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
具有泛型的对象的oop Java数组   爪哇丑陋的数字找到第1500名UVA在线评委   SpringJava。lang.IllegalStateException:自动连线批注至少需要一个参数   java为什么我的系统找不到我的属性文件?   java有没有办法让Maven同时构建1.5和1.6字节码JAR?   java通过Sailfin中的header进行操作   使用向量、距离和图形   如果提供的登录信息是错误的,为什么java控件不进入else部分和Toast?   java如何为电子商务安卓应用程序存储产品列表   java保存声音首选项Libgdx Android   java无法在测试单元中调用JpaRepository   java使用批处理更新Cassandra表中的选定列,而不将其他列值设为null   java如何在log4j2中的手动代码配置中向appender添加级别?   从ImageIO返回的java Null。读取(新的ByteArrayInputStream(bs));   java不确定如何防止此Arraylist处于可编辑状态   netbeans中的java更改清单(TrustedLibrary=true属性)   java无法使用RestTemplate和Spring数据REST发布具有关系的新实体