#coding:utf-8
import xlrd
from xlutils.copy import copy
class readExcel(object):
def __init__(self,path):
self.path = path
def getSheet(self):
#通过索引获取一个工作表
data = xlrd.open_workbook(self.path)
sheet = data.sheet_by_index(0)
return sheet
#获取表的行数
def getRows(self):
row = self.getSheet().nrows
return row
#获取列数
def getCol(self):
col = self.getSheet().ncols
return col
#分别获取每一列的数值
def getUid(self):
TestUid = [] #存放第一列数据
for i in range(1,self.getRows()):
TestUid.append(self.getSheet().cell(i,0).value)
return TestUid
def getName(self):
TestName =[]
for i in range(1,self.getRows()):
TestName.append(self.getSheet().cell(i,1).value)
return TestName
def getUrl(self):
TestUrl = [] #存放url
for i in range(1,self.getRows()):
TestUrl.append(self.getSheet().cell(i,2).value)
return TestUrl
def getMethod(self):
TestMethod = [] #存放接口类型
for i in range(1,self.getRows()):
TestMethod.append(self.getSheet().cell(i,3).value)
return TestMethod
def getData(self):
TestData = [] #存放接口传送数据
for i in range(1, self.getRows()):
TestData.append(self.getSheet().cell(i, 4).value)
return TestData
def getCode(self):
TestCode = []
for i in range(1,self.getRows()):
TestCode.append(self.getSheet().cell(i,5).value)
return TestCode
def writeResults(self): #copy一个表,然后新建一个表保存结果
data = xlrd.open_workbook(self.path)
book = copy(data)
return book
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
python+excel+unittest.rar (7个子文件)
python+excel+unittest
data_driver.py 2KB
data2.xlsx 6KB
test_api_way.py 1KB
test_case.py 2KB
data_driver.pyc 3KB
test_api_way.pyc 2KB
data.xlsx 11KB
共 7 条
- 1
资源评论
- 土花卷2017-11-22框架太简单,不如在git上找
- We_IceFly2020-10-21资料,非常有用!
xuxiasheng
- 粉丝: 1
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功