python-获取 Excel 表格数据

cls = []
# 获取测试用例文件路径
x_path = os.path.join(Excel路径, "testFile", Excel的名字)
# 打开测试用例文件
file = open_workbook(x_path)
# 根据 sheet_name 找到要打开的 sheet
sheet = file.sheet_by_name(sheet的名字)
# 得到行数
rows = sheet.nrows
for i in range(rows):
    if sheet.row_values(i)[0] != u'case_name':
       cls.append(sheet.row_values(i))

for c in cls:
    print(c)

猜你喜欢

转载自www.cnblogs.com/lilyo/p/12017027.html