python 查找文件夾下所有文件 實現(xiàn)代碼
更新時間:2009年07月01日 00:48:05 作者:
python 查找文件夾下所有文件,需要的朋友可以參考下。
復(fù)制代碼 代碼如下:
def find_file_by_pattern(pattern='.*', base=".", circle=True):
'''''查找給定文件夾下面所有 '''
re_file = re.compile(pattern)
if base == ".":
base = os.getcwd()
final_file_list = []
print base
cur_list = os.listdir(base)
for item in cur_list:
if item == ".svn":
continue
full_path = os.path.join(base, item)
if full_path.endswith(".doc") or \
full_path.endswith(".bmp") or \
full_path.endswith(".wpt") or \
full_path.endswith(".dot"):
continue
# print full_path
bfile = os.path.isfile(item)
if os.path.isfile(full_path):
if re_file.search(full_path):
final_file_list.append(full_path)
else:
final_file_list += find_file_by_pattern(pattern, full_path)
return final_file_list
相關(guān)文章
科學(xué)計算NumPy之Ndarray運算函數(shù)操作示例匯總
這篇文章主要為大家介紹了科學(xué)計算NumPy之Ndarray運算函數(shù)操作示例匯總,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-04-04Python read函數(shù)按字節(jié)(字符)讀取文件的實現(xiàn)
這篇文章主要介紹了Python read函數(shù)按字節(jié)(字符)讀取文件的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-07-07