您的位置:首页 > 编程语言 > Python开发

python实现,按文件名搜索制定路径下的文件

2015-11-12 17:57 946 查看
#!/usr/bin/env python3
# coding=utf-8

import os

def search(path=".", name="1"):
for item in os.listdir(path):
item_path = os.path.join(path, item)
if os.path.isdir(item_path):
search(item_path, name)
elif os.path.isfile(item_path):
if name in item:
print(item_path)

if __name__ == "__main__":
search(path=r"D:\360",name="dll")
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python