久久久精品一区ed2k-女人被男人叉到高潮的视频-中文字幕乱码一区久久麻豆樱花-俄罗斯熟妇真实视频

python如何列出文件夾所有文件-創(chuàng)新互聯(lián)

這篇文章主要介紹python如何列出文件夾所有文件,文中介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們一定要看完!

主要從事網(wǎng)頁設(shè)計、PC網(wǎng)站建設(shè)(電腦版網(wǎng)站建設(shè))、wap網(wǎng)站建設(shè)(手機版網(wǎng)站建設(shè))、自適應(yīng)網(wǎng)站建設(shè)、程序開發(fā)、微網(wǎng)站、重慶小程序開發(fā)等,憑借多年來在互聯(lián)網(wǎng)的打拼,我們在互聯(lián)網(wǎng)網(wǎng)站建設(shè)行業(yè)積累了豐富的網(wǎng)站設(shè)計制作、成都網(wǎng)站建設(shè)、網(wǎng)絡(luò)營銷經(jīng)驗,集策劃、開發(fā)、設(shè)計、營銷、管理等多方位專業(yè)化運作于一體,具備承接不同規(guī)模與類型的建設(shè)項目的能力。

導(dǎo)入庫

首先,我們需要os庫中的三種方法。

l listdir:檢索目錄的內(nèi)容(目錄和文件)。

l join:將兩個組件組合成一條路徑。

l isfile:如果給定的路徑組件是一個文件,則返回true。

from os import listdir
from os.path import join, isfile

檢索目錄的內(nèi)容

導(dǎo)入必要的方法后,該設(shè)置目錄的路徑并檢索其內(nèi)容了。

from os import listdir
from os.path import join, isfile
directory_path = "/some/path"
contents = listdir(directory_path)

篩選目錄

現(xiàn)在我們有了目錄的所有內(nèi)容,是時候過濾掉目錄了—僅保留文件。

from os import listdir
from os.path import join, isfile
directory_path = "/some/path"
contents = listdir(directory_path)
files = filter(lambda f: isfile(join(directory_path,f)),contents)

files為列表以打印內(nèi)容

from os import listdir
from os.path import join, isfile
directory_path = "/Users/jhsu/Desktop"
contents = listdir(directory_path)
files = filter(lambda f: isfile(join(directory_path,f)),contents)
print(files) # <filter object at 0x10a5203a0>
print(list(files)) # [list of files]

以上是python如何列出文件夾所有文件的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

新聞名稱:python如何列出文件夾所有文件-創(chuàng)新互聯(lián)
分享路徑:http://sd-ha.com/article44/goeee.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供手機網(wǎng)站建設(shè)營銷型網(wǎng)站建設(shè)、微信小程序、靜態(tài)網(wǎng)站外貿(mào)建站、網(wǎng)站策劃

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

綿陽服務(wù)器托管