[Turn] Python Find all excel files in a folder

 

# - * - Coding: UTF-8 - * - 
# author: Baoshan 

Import os 

dirname = r ' D: \ 0.shenma \ 01 Liaocheng data \ 01 data \ 02 Liaocheng Yearbook data \ 2017 Yearbook... ' 
Filename = " * .xls " 

Result = []
 DEF Search (dirname = dirname, filename = "" ):
     for Item in the os.listdir (dirname): 
        item_path = the os.path.join (dirname, Item)
         IF os.path.isdir ( item_path): 
            Search (item_path, filename) 
        elif os.path.isfile (item_path):
             IF filename in item:
                global result
                result.append(item_path +";")
                print(item_path+";")


if __name__ == '__main__':
    search(dirname, filename)

 

 

Transfer: https://www.cnblogs.com/hyacinthwyd/p/8997917.html

 

Thank you!

Guess you like

Origin www.cnblogs.com/zhzhang/p/11605345.html