没有完整路径的Python Glob-仅文件名 [英] Python Glob without the whole path - only the filename

查看:94
本文介绍了没有完整路径的Python Glob-仅文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以在目录上使用glob来获取具有特定扩展名的文件,而只能获取文件名本身,而不是整个路径?

Is there a way I can use glob on a directory, to get files with a specific extension, but only the filename itself, not the whole path?

推荐答案

使用os.path.basename(path)获取文件名.

这篇关于没有完整路径的Python Glob-仅文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆