這篇文章將為大家詳細(xì)講解有關(guān)python如何查詢文件夾下excel的sheet,小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。
具體內(nèi)容如下
import os,sys,stat,xlrd path=r"F:\360Downloads" sheet = input("sheet name:") def del_file(path): ls = os.listdir(path) for i in ls: c_path = os.path.join(path, i) if os.path.isdir(c_path): del_file(c_path) elif os.path.splitext(c_path)[1] == '.xlsx': workbook = xlrd.open_workbook(c_path) worksheets = workbook.sheet_names() if (u''+sheet in worksheets): print(c_path) print(worksheets) del_file(path)
關(guān)于“python如何查詢文件夾下excel的sheet”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。