技术标签: python
需求如下:
读取Excel表格中的sheet也中的测试数据,并转换成json格式数据
#coding:utf-8
import json
import xlrd
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
def tableToJson():
source = xlrd.open_workbook(r"C:\Users\Administrator\Desktop\0603\0603Interface.xlsx")
# 获取workbook中所有的sheet
sheets = source.sheets()
# 循环遍历所有sheet
print len(sheets) #15
list = [] #字典列表
totalList = [] #json列表
for i in range(len(sheets)):
table = source.sheet_by_index(i)
print "loop",i #第几个sheet
keys = table.col_values(1) #获取第i个表第2列的所有值
for j in xrange(3,table.ncols):
test_value = table.col_values(j) #获取第i个表第4列起的值作为用例的参数值
for k in range(len(test_value)):
#test_value[k] = test_value[k].decode('gbk').encode('utf-8')
s = test_value[k]
#print s
#test_name = table.cell(0,j).value #获取第i个表第4列起的每列第一行内容作为用例名
data = dict(zip(keys,test_value)) #等长两列表转为字典
list.append(data)
data1 = {}
data1[sheets[i].name] = list
data1_to_json = json.dumps(data1,ensure_ascii=False,encoding="gb2312") #将列表中的unicode转中文
print u"用例数据:",data1_to_json
totalList.append(data1_to_json)
list = []
return totalList
if __name__ == '__main__':
jsondata = tableToJson()
#print u'test_name_debug:',jsonData
#写入文件
f = open(r"F:\TestData.json",'w+')
for i in jsondata:
f.write(i)
f.write("\n")
#f.write(jsondata)
f.close()
1.下载安装Unity官网传送门:http://www.unity3d.com/ 下载完就是傻瓜式地下一步下一步········然后安装。2.高通的Vuforia SDK官网传送门:https://developer.vuforia.com/①获得一个licence key按照要求内容填写,注册一个账号,登录。下一步下一步下一步②下载Vuforia SDK下一步:点击下载SDK3.打开Un...
<br />1、用图片代替提交按钮submit和重置按钮reset,给图片加onclick事件<br /><script language="javascript"><br />function fsubmit(obj){<br />obj.submit();<br />}<br />function freset(obj){<br />obj.reset();<br />}<br /></script><br /><form id="form1" nam
目录一、引言 二、interaction中select选取feature 三、interaction中draw与modify修改feature 四、总结 一、引言 gis中最基础的就是空间查询,鼠标点击事件获取要素,同时我们经常要对要素进行添加与修改。这些在之前的webgis开发中都要自己去实现,现在openlayer中已经用很多类封装实现了这些功...
不允许不使用 var 关键字去创建全局变量,抛出 ReferenceError不允许对变量使用 delete 操作符,抛 ReferenceError不可对对象的只读属性赋值,不可对对象的不可配置属性使用 delete 操作符,不可为不可拓展的对象添加属性,均抛 TypeError对象属性名必须唯一函数中不可有重名参数在函数内部对修改参数不会反映到 arguments 中淘汰 arguments.callee 和 arguments.caller不可在 if 内..
I have a scenario where I'm passing data from a reducer into my react state.data:{"id": 1,"title": "Test","content": {"body": "sdfsdf""image": "http://example.com"}}Using componentWillRecieveProps, th...
九、连接查询之sql 99标准作者:IrainQQ:2573396010微信:18802080892Github文件:九、连接查询之sql 99标准视频链接:连接查询之sql 99标准sql 99标准语法:select 查询列表from 表1 别名【连接类型】join 表2 别名on 连接条件【where 筛选条件】【group by 分组】【having 筛选条...
SpringBoot自动配置注解原理解析1. SpringBoot启动主程序类:import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import com.taobao.pandora.boot.PandoraBootstrap;/** * Pandora Boot应用的入口类 * <p>Lo
项目需求我会有很多个picker选择器,我一开始是这样写的<mt-picker :slots="windowList[index].weightPicker"></mt-picker>在data里面有一个windowList数组,上面的index是根据选择的弹窗的类型传入的值,选择windowList第index个子集;但是这样有一直报错;报错如下...
Performing system checks...Exception in thread django-main-thread:Traceback (most recent call last):File "/root/.virtualenvs/test12/local/lib/python3.6/site-packages/django/template/utils.py", line 66...
合适的工作难找?最新的招聘信息也不知道?AI 求职为大家精选人工智能领域最新鲜的招聘信息,助你先人一步投递,快人一步入职!英属哥伦比亚大学英属哥伦比亚大学(UBC) 位于位于世界上最安全宜...
使用Series出现警告:原代码:series[list(range(1,5))]C:\Python36\lib\site-packages\pandas\core\series.py:696: FutureWarning: Passing list-likes to .loc or [] with any missing label will raiseKeyError in the futur...
System.exit() 的本质是通知 JVM 关闭。一般来说,有两种禁用 System.exit() 的办法:安全管理器安全策略本质都是JRE 提供的本地实现,在执行之前进行权限判断。因为System.exit() 是一种很暴力的手段,如果在 Client 模式下自己写个小程序无所谓,但是在 Server 上多个程序、或者多线程时就会有很大的麻烦