5.6节运行excel_util.py报错,提示格式错误,可是我是按照课程一步一步写的。没发现哪里错了
excel_util.py如下:
#coding=utf-8
import xlrd
class ExcelUtil:
def init(self,excel_path=None,index=None):
if excel_path == None:
excel_path = "/Users/hustcxy/Documents/SeleniumPython/config/casedata.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()
ex.get_data()