获得徽章 0
#码上掘金# 我们生产一张随机图片~ code.juejin.cn
1
#码上掘金# 旋转五角星? code.juejin.cn
评论
#码上掘金# 排序 code.juejin.cn
评论
#码上掘金# 下面的代码计算你假期还剩余多少 code.juejin.cn
评论
我感觉我啥也不会做,但是活到了今天。
评论
赞了这篇沸点
#我的五一计划清单# 不出门旅游,今天在家把床上的被子还有衣服都洗干净了。
评论
#码上掘金# 螺旋桨之五一螺旋桨 code.juejin.cn
评论
#码上掘金# 随机迷宫,怎么没有出口 code.juejin.cn
评论
#码上掘金# 密码生成器迷幻不 code.juejin.cn
1
#码上掘金# #经典代码的味道 code.juejin.cn
评论
#码上掘金# 每日笑话~ code.juejin.cn
评论
虚幻引擎开发工程师
#码上掘金# 新入门的看得懂这段代码吗 code.juejin.cn
1
虚幻引擎开发工程师
虚幻引擎开发工程师
#码上掘金# import os

# 定义文件查找函数
def search_files(path, name=None, ext=None):
result = []
for root, dirs, files in os.walk(path):
for file in files:
if name and name not in file:
continue

if ext and not file.endswith(ext):
continue

result.append(os.path.join(root, file))

return result

# 在指定路径下查找指定名称和扩展名的文件
path = "/path/to/search"
name = "example"
ext = ".txt"

result = search_files(path, name=name, ext=ext)

if result:
print(f"Found {len(result)} files:")
print("-----------------------")
for file in result:
print(file)
else:
print("No files found.")#码上掘金#
展开
1
虚幻引擎开发工程师
虚幻引擎开发工程师
下一页
个人成就
文章被点赞 10
文章被阅读 7,681
掘力值 127
收藏集
9
关注标签
22
加入于