用Python遍历C盘dll文件的方法
作者:goldensun 时间:2023-04-27 20:15:27
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>
标签:Python
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Mysql 本地计算机无法启动 mysql 服务 错误 1067:进程意外终止。
2024-01-27 19:30:56
js捕捉窗口的关闭与刷新
2008-10-08 10:20:00
区别JavaScript函数声明与变量声明
2024-04-18 09:34:42
python字符串,元组,列表,字典互转代码实例详解
2022-03-01 22:51:55
SQLServer 2005 实现数据库同步备份 过程-结果-分析
2012-07-11 15:56:55
在Python编程过程中用单元测试法调试代码的介绍
2023-12-10 02:16:46
python optparse模块使用实例
2021-02-03 22:01:36
Python Selenium 之数据驱动测试的实现
2021-12-16 22:45:27
![](https://img.aspxhome.com/file/2023/9/68259_0s.png)
Vue3 通过作用域插槽实现树形菜单嵌套组件
2024-05-28 15:42:28
![](https://img.aspxhome.com/file/2023/1/123201_0s.jpg)
mac os10.12安装mysql5.7.18教程
2024-01-19 14:08:27
![](https://img.aspxhome.com/file/2023/7/76457_0s.jpg)
PYTHON正则表达式 re模块使用说明
2021-11-25 15:06:50
python3.7调试的实例方法
2022-09-22 17:16:24
![](https://img.aspxhome.com/file/2023/8/82758_0s.png)
Javascript typeof 用法
2013-10-20 20:49:40
Django中使用session保持用户登陆连接的例子
2021-08-29 03:27:30
jasypt 集成SpringBoot 数据库密码加密操作
2024-01-26 03:34:48
![](https://img.aspxhome.com/file/2023/6/129286_0s.jpg)
纯ASP(VBscript)写的全球IP地址搜索程序
2007-09-27 13:28:00
Tensorflow卷积实现原理+手写python代码实现卷积教程
2021-12-21 20:12:52
![](https://img.aspxhome.com/file/2023/5/105045_0s.jpg)
vscode调试container中的程序的方法步骤
2022-03-06 14:20:25
![](https://img.aspxhome.com/file/2023/8/130898_0s.png)
Python arrow 更好的日期时间模块
2022-02-08 14:06:15
![](https://img.aspxhome.com/file/2023/4/105064_0s.png)
Python实现爬取网页中动态加载的数据
2021-08-11 18:35:27
![](https://img.aspxhome.com/file/2023/7/102857_0s.jpg)