python實(shí)現(xiàn)將文件夾下面的不是以py文件結(jié)尾的文件都過(guò)濾掉的方法
如下所示:
dir_in = os.path.join(os.path.dirname(__file__), r"oldApp")
dir_in = unicode(dir_in, r"GBK")
dir_out = os.path.join(os.path.dirname(__file__), r"newApp")
dir_out = unicode(dir_out, r"GBK")
rediret_file_path_list = []
soure_file_path_out_list = []
for root, dirs, files in os.walk(dir_in):
for file in files:
# print('root=%s' %root)
# print('1111 file=%s' %file)
# filter file extend name not .py
filter_file = file.split('.')
if filter_file[1] != 'py':
continue
soure_file_path_out = os.path.join(root, file)
# print(soure_file_path_out)
soure_file_path_out_list.append(soure_file_path_out)
root_new = root.replace(r'oldApp', r'newApp')
if not os.path.exists(root_new):
os.makedirs(root_new)
rediret_file_path = os.path.join(root_new, file)
# print('rediret_file_path=%s' %rediret_file_path)
rediret_file_path_list.append(rediret_file_path)
以上這篇python實(shí)現(xiàn)將文件夾下面的不是以py文件結(jié)尾的文件都過(guò)濾掉的方法就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
python基于opencv檢測(cè)程序運(yùn)行效率
這篇文章主要介紹了python基于opencv檢測(cè)程序運(yùn)行效率,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-12-12
Python socket模塊方法實(shí)現(xiàn)詳解
這篇文章主要介紹了Python socket模塊方法實(shí)現(xiàn)詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-11-11
在python下實(shí)現(xiàn)word2vec詞向量訓(xùn)練與加載實(shí)例
這篇文章主要介紹了在python下實(shí)現(xiàn)word2vec詞向量訓(xùn)練與加載實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-06-06
Django rest framework實(shí)現(xiàn)分頁(yè)的示例
這篇文章主要介紹了Django rest framework實(shí)現(xiàn)分頁(yè)的示例,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-05-05
python 利用pandas將arff文件轉(zhuǎn)csv文件的方法
今天小編就為大家分享一篇python 利用pandas將arff文件轉(zhuǎn)csv文件的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-02-02
Python實(shí)現(xiàn)列表中非負(fù)數(shù)保留,負(fù)數(shù)轉(zhuǎn)化為指定的數(shù)值方式
這篇文章主要介紹了Python實(shí)現(xiàn)列表中非負(fù)數(shù)保留,負(fù)數(shù)轉(zhuǎn)化為指定的數(shù)值方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-06-06

