python获取excelsheet名称
python查询文件夹下excel的sheet名代码实例本文实例为大家分享了python查询文件夹下excel的sheet的具体代码,供大家参考,具体内容如下
|
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) |
以上所述是小编给大家介绍的python查询文件夹下excel的sheet名详解整合,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对开心学习网网站的支持!
原文链接:https://blog.csdn.net/weixin_38883338/article/details/88959644