要实现的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第三方库


热门话题
Java Square类   java Android RecyclerView内部视图寻呼机   java类变量:公共访问只读,但私有访问r/w   java不兼容ClassChangeError java8   安卓java on on参数,如参数iNIT.C++C++   java如何在下面的代码中根据我的喜好设置JTextArea和JTextField的大小?   java使用CustomAdapter更改ListView的显示方式   jakarta ee什么是Java Servlet?   传递给Javasocket程序的参数   java为什么我的计划任务在这两者之间有很长的延迟   Java“迭代器”关键字   java获取数据库SQLite Android中插入行的行ID   网络如何在Java应用程序中设置H2嵌入式数据库,以便在小型网络中使用?   数组Java:写出所有包含K1的Nbit序列   java返回随机字符串键的整数值   在java中解析到日期的字符串时保留时区   java如何修复“运行配置错误:[在SDK中找不到Rails]”?   Java包装器OutofMemory