Python_API_File and Directory Access_glob.glob
2012-03-28 22:29
399 查看
API文档:
glob
The glob module finds all the pathnames matching a specified pattern according to the rules used by the Unix shell. No tilde expansion is done, but*,?,
and character ranges expressed with[] will be correctly
4000
matched. This is done by using theos.listdir()
andfnmatch.fnmatch() functions in concert, and not by actually invoking a subshell.
翻译文档:
用于匹配目录路径,返回一个list。这个函数实际调用的是os.listdir()和fnatch.fnmatch()两个函数来执行。不是通过shell来执行匹配
例子:
import glob
pathStr = 'F:\\pyWorkSpace\\notes\\dPython\\music\\_singles\\'
print glob.glob(pathStr+'*.mp3')
print glob.glob(pathStr+'a*.mp3')
输出:
['F:\\pyWorkSpace\\notes\\dPython\\music\\_singles\\aa.mp3']
['F:\\pyWorkSpace\\notes\\dPython\\music\\_singles\\aa.mp3']
glob
The glob module finds all the pathnames matching a specified pattern according to the rules used by the Unix shell. No tilde expansion is done, but*,?,
and character ranges expressed with[] will be correctly
4000
matched. This is done by using theos.listdir()
andfnmatch.fnmatch() functions in concert, and not by actually invoking a subshell.
翻译文档:
用于匹配目录路径,返回一个list。这个函数实际调用的是os.listdir()和fnatch.fnmatch()两个函数来执行。不是通过shell来执行匹配
例子:
import glob
pathStr = 'F:\\pyWorkSpace\\notes\\dPython\\music\\_singles\\'
print glob.glob(pathStr+'*.mp3')
print glob.glob(pathStr+'a*.mp3')
输出:
['F:\\pyWorkSpace\\notes\\dPython\\music\\_singles\\aa.mp3']
['F:\\pyWorkSpace\\notes\\dPython\\music\\_singles\\aa.mp3']
相关文章推荐
- Python_API_File and Directory Access_os.path.expanduser
- Python_API_File and Directory Access_os.path.splitext
- Python_API_File and Directory Access_os.path.split
- Python_API_File and Directory Access_os.path.normcase
- Python_API_File and Directory Access_os.path.join
- python文件和目录访问File and Directory Access
- python库的学习系列之 10. File and Directory Access
- python文件和文件夹訪问File and Directory Access
- Python SOAP API, HTTP POST and HTTP GET
- Remove the .pyc files from current directory tree and from svn (Python recipe) by Senthil Kumaran
- 安装pycrypto出现“fatal error: Python.h: No such file or directory”错误
- Issue 71 - pymssql - Undefined symbols on Mac, CentOS, Redhat with pre-compiled build - A fast MS SQL Server client library for Python directly using C API instead of ODBC. It is Python DB-API 2.0 compliant. Works on Linux, *BSD, Solaris, Mac OS X and Win
- Python.h:No such file or directory
- android java.io.IOException: open failed: ENOENT (No such file or directory)-api23+权限受权
- Python Web-第三周-Networks and Sockets(Using Python to Access Web Data)
- python: can't open file 'django-admin': [Errno 2] No such file or directory
- 解决DPDK脚本python执行时“OSError: [Errno 2] No such file or directory”的问题
- How to Access and Use the Windows Hosts File in Windows 7 and Vista
- 解决fatal error: Python.h: No such file or directory
- 出现Python.h:No such file or directory错误的解决方案