用Python遍历C盘dll文件的方法,
用Python遍历C盘dll文件的方法,
python 的fnmatch 还真是省心,相比于 java 中的FilenameFilter ,真是好太多了,你完成不需要去实现什么接口。
fnmatch 配合 os.walk() 或者 os.listdir() ,你能做的事太多了,而且用起来相当 easy。
# coding: utf-8 """ 遍历C盘下的所有dll文件 """ import os import fnmatch def main(): f = open('dll_list.txt', 'w') for root, dirs, files in os.walk('c:\\'): for name in files: if fnmatch.fnmatch(name, '*.dll'): f.write(os.path.join(root, name)) f.write('\n') f.close() print 'done...' if __name__=='__main__': main()</pre>
相关内容
- 使用wxPython获取系统剪贴板中的数据的教程,wxpython剪贴
- 浅谈Python中数据解析,浅谈python解析
- python递归计算N!的方法,python递归计算n
- 用Python中的字典来处理索引统计的方法,python索引
- Python封装shell命令实例分析,pythonshell
- Python实现方便使用的级联进度信息实例,python方便使用
- Python获取任意xml节点值的方法,python获取xml节点
- 进一步探究Python的装饰器的运用,探究python装饰
- Python记录详细调用堆栈日志的方法,python调用堆栈日志
- Python调用命令行进度条的方法,python命令行进度条
评论关闭