excel文件写入数据
- 接口测试脚本中可能会遇到上传文件的接口,而且接口需要正确的数据,则我们需要在脚本中导入正确的数据,保存文件通过接口上传。
from fuction.Random import Random
import xlrd
from xlutils.copy import copy
import os
class Excel:
def __init__(self):
self.random = Random()#之前写的随机获取数据
def write_excel_xls_append(self,path,value):
"""写入excel"""
index = len(value) # 获取需要写入数据的行数
workbook = xlrd.open_workbook(path) # 打开工作簿
sheets = workbook.sheet_names(