美文网首页软件测试技能
读取excel中的用例

读取excel中的用例

作者: 笑起来真好看ccn | 来源:发表于2019-10-31 09:04 被阅读0次

from openpyxlimport load_workbook

class DoExcel:

def __init__(self,file_path,sheet_name):

self.file_path=file_path

self.sheet_name=sheet_name

def do_excel(self):

wb=load_workbook(self.file_path)

sheet=wb[self.sheet_name]

test_data=[]

for iin range(2,sheet.max_row+1):

sub_data={}

sub_data['id']=sheet.cell(i,1).value

sub_data['title'] = sheet.cell(i,2).value

test_data.append(sub_data)

return test_data

if __name__=='__main__':

test_data=DoExcel('cases.xlsx','userRegister').do_excel()

for itemin test_data:

print(item)

相关文章

网友评论

    本文标题:读取excel中的用例

    本文链接:https://www.haomeiwen.com/subject/swmepctx.html