#coding=utf-8
import xlrd
class ExcelUtil():
def __init__(self,excel_path=None,index=None):
if excel_path == None:
excel_path = r"G:\study\Python\projects\Imooc\config\userData.xls"
if index == None:
index = 0
self.data = xlrd.open_workbook(excel_path)
self.table = self.data.sheets()[index]
#行数
self.rows = self.table.nrows
#[[],[]]
def get_data(self):
result = []
for i in range(self.rows):
col = self.table.row_values(i)
result.append(col)
return result
if __name__ == '__main__':
ex = ExcelUtil()
print(ex.get_data())
excel_util
最新推荐文章于 2023-02-28 21:48:26 发布