# 遍历目标目录下的所有文件名 defall_path(dirname): result = [] # 当前主目录,当前主目录下的所有目录,当前主目录下的所有文件 for maindir, subdir, file_name_list in os.walk(dirname): for filename in file_name_list: if filename.endswith('xls') or filename.endswith('xlsx'): apath = os.path.join(maindir, filename) # 合并成一个完整路径 result.append(apath) return result
# 获取表的数目 nrows = sheet.nrows for i inrange(nrows): # 参数可根据实际情况调整 if i < 2: continue if sheet.row_values(i)[2] == '': continue records.append(sheet.row_values(i)) return records