[電源を入れる] Pythonは、すべてのフォルダ内のファイルをエクセル検索します

 

- * -コーディング:UTF-8 - * - 
#1 著者:宝山

インポートのOS 

のdirname = R ' D:\ 0.shenma 2017年鑑\ 02聊城年鑑データ\ 01データ\ 01聊城データ\ ... ' 
ファイル名 = " * .XLS " 

結果 = []
 DEF検索(dirnameは= dirnameは、ファイル名= "" ):
     用のアイテムのos.listdir(dirnameは):
        item_pathは = os.path.join(dirnameは、項目)
         IF os.path.isdirは( item_path):
            検索(item_path、ファイル名)
        ELIFのos.path.isfile(item_path):
             IFファイル名ののアイテム:
                 グローバル結果
                result.append(item_path + " ; " プリント(item_path + " ; " 


であれば __name__ == ' __main__ ' 
    検索(dirnameは、ファイル名)

 

 

転送:https://www.cnblogs.com/hyacinthwyd/p/8997917.html

 

ありがとうございます!

おすすめ

転載: www.cnblogs.com/zhzhang/p/11605345.html