欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python3指定路徑尋找符合匹配模式文件

 更新時(shí)間:2015年05月22日 11:29:18   作者:work24  
這篇文章主要介紹了Python3指定路徑尋找符合匹配模式文件,涉及Python文件查找與模式匹配的相關(guān)技巧,需要的朋友可以參考下

本文實(shí)例講述了Python3指定路徑尋找符合匹配模式文件。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:

這里給定一個(gè)搜索路徑,需要在此目錄中找出所有符合匹配模式的文件

import glob, os 
def all_files(pattern, search_path, pathsep = os.pathsep): 
  for path in search_path.split(pathsep): 
    for match in glob.glob(os.path.join(path, pattern)): 
      yield match 
print(type(all_files('*.s', 'd:\\pm\\pm')))      
print(all_files('*.s', 'd:\\pm\\pm').__next__()) 
for match in all_files('*.s', 'd:\\pm\\pm'):   
  print(match)

希望本文所述對(duì)大家的Python3程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論