您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

用Python遍历C盘dll文件的方法

2025/4/1 21:57:55发布31次查看
python 的fnmatch 还真是省心,相比于 java 中的filenamefilter ,真是好太多了,你完成不需要去实现什么接口。
fnmatch 配合 os.walk() 或者 os.listdir() ,你能做的事太多了,而且用起来相当 easy。
# coding: utf-8遍历c盘下的所有dll文件import osimport fnmatchdef 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()
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product