开发者

using wild card when listing directories in python

how can I use wild cars like '*' when getting a list of files inside a directory in Python? for example, I want something like:

os.listdir('foo/*bar*/*.txt') 

which would return a list of all the files ending in .txt in directories that have bar in their name inside of the foo parent directory.

how can I do this?

thanks.开发者_如何学运维


glob.glob for the win.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜