from openpyxl import load_workbook class Case: def __init__(self): self.case_id = None self.title = None self.method = None self.url = None self.data = None self.expected = None self.actually = None self.result = None
class ReadData: def __init__(self, file_name): self.file_name = file_name self.wb = load_workbook(self.file_name) def read_data(self, sheet_name): self.sheet_name = sheet_name sheet =self.wb[self.sheet_name] case_data = [] for row in range(2, int(sheet.max_row)+1): case = Case() case.case_id = sheet.cell(row, 1).value case.title = sheet.cell(row, 2).value case.method = sheet.cell(row, 3).value case.url = sheet.cell(row, 4).value case.data = sheet.cell(row, 5).value case.expected = sheet.cell(row, 6).value case_data.append(case) return case_dataif __name__==‘__main__‘:
原文地址:https://www.cnblogs.com/sophia-985935365/p/12629524.html
时间: 2024-10-20 11:47:46