import xlrd
def excel_to_list(file_path):
# 导入需要读取的Excel表格的路径
workbook = xlrd.open_workbook(file_path)
# workbook = xlrd.open_workbook(file_path)
sheets_01 = workbook.sheet_by_name('sheet1')
# sheets_01 = workbook.sheets()[0]
# 创建一个空列表,存储Excel的数据
results = []
# 忽略 excel 第一行的表头
list1 = [index for index in range(sheets_01.nrows) if index != 0]
# 将excel表格内容导入到results列表中
HeaderList = HeaderLine.split(",")
for rown in list1:
_dic = {}
for i in HeaderList:
_dic[i] = sheets_01.cell_value(rown, HeaderList.index(i))
results.append(_dic)
return results