当前位置:主页 > 软件编程 > Python代码 >

python查询文件夹下excel的sheet名代码实例

时间:2021-02-19 15:20:14 | 栏目:Python代码 | 点击:

本文实例为大家分享了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)

您可能感兴趣的文章:

相关文章